Compare commits

...

429 Commits

Author SHA1 Message Date
Juraj Bednar
bb8d10a0b9
Update README.md (#112)
@pavlenex said on btcpayserver chat that this is not maintained, probably a good idea to mention it in the documentation, since from docs it seems that it is alpha that is going to receive some care.
2024-10-21 15:51:03 +02:00
Kukks
b19665152d bump 2021-11-05 11:08:12 +01:00
Kukks
561c676758 use custom exchangesharp until they merge PR 2021-11-05 11:08:08 +01:00
Kukks
6699e73ed6 bump 2021-10-05 14:13:58 +02:00
Kukks
c5dfbf336e Bump ExchangeSharp 2021-10-05 14:13:38 +02:00
Kukks
e74a996424 bump 2021-07-12 08:44:52 +02:00
juandelcid
96c3747ad9 Send MarketSymbol on GetOrderDetailsAsync (#95)
Binance requires MarketSymbol when you query an order.
2021-07-12 08:44:00 +02:00
Kukks
c7fe58200f small fixes and adjustments around btcpay auth 2021-03-18 09:38:14 +01:00
Pavlenex
8e3051e61b
Merge pull request #83 from MaxHillebrand/patch-1
[typo] remove double word
2021-02-03 16:43:42 +01:00
Pavlenex
d84d4bdf7f
Merge pull request #72 from britttttk/readme-dca
Add DCA to readme
2021-02-03 16:43:31 +01:00
Max Hillebrand
003c261909
[typo] remove double word 2021-02-03 16:22:42 +01:00
Dennis Reimann
4dc82b81c5
Fix headline level (#80)
Noticed this while working on the docs search.
2020-12-04 10:26:52 +01:00
britttttk
d36ead30a7
fix case sensitive command and add link to FAQ (#71) 2020-10-13 09:00:54 +02:00
Britt Kelly
4cb2a23900 Add DCA to readme 2020-09-11 18:19:16 -06:00
ɹǝƃıǝ⅁ ɯo⊥
b3faa84cf3
Prevent model invalidation after sent email (#66)
Removed the confirmation message as it invalidates the model, preventing it from being saved.
2020-08-06 09:25:30 +02:00
Kukks
b413816797 set first user to admin even if from btcpay 2020-07-17 12:37:05 +02:00
Kukks
048b59c261 set default mode to list
closes #53
2020-07-17 12:36:49 +02:00
Kukks
7de6647e65 Refactor LoginWithBtcPay 2020-07-17 11:35:32 +02:00
Kukks
f4a837f36f fix login 2020-07-16 10:38:02 +02:00
Kukks
140d2c206a Login with BTCPay feature 2020-07-15 14:40:43 +02:00
Kukks
50c1651cba update 2020-06-21 14:07:47 +02:00
Kukks
a497084b34 fix build 2020-06-21 13:47:18 +02:00
Kukks
051a27fd86 bump version 2020-06-21 13:38:23 +02:00
Kukks
124982bd94 fix plenty of warnings 2020-06-21 13:37:51 +02:00
Kukks
97f682115c Add DCA guide 2020-06-21 13:28:03 +02:00
Kukks
39bd13bb25 use custom exchanegsharp until next release 2020-06-21 12:54:31 +02:00
Kukks
2ef1e353e7 Add DCA preset 2020-06-21 09:56:55 +02:00
Kukks
8334969f93 bump packages 2020-06-21 09:15:18 +02:00
Kukks
21ecf986f1 fix algolia autocomplete search dark theme color 2020-06-21 09:13:11 +02:00
Kukks
cb6fa66300 opt out telemetry 2020-06-21 08:52:08 +02:00
Dennis Reimann
32f21e5306
Fix links (#64)
Found these while working on a broken link check for the docs.
2020-06-18 07:28:11 +02:00
Dennis Reimann
5d0b771a36
Apply design guidelines (#62)
* Add design basics

* Minor footer improvement
2020-06-16 17:26:03 +02:00
Kukks
435ebf8909 bump packages 2020-05-27 09:17:49 +02:00
Kukks
323f7e8481 remove debug code 2020-05-27 08:46:52 +02:00
Kukks
2d7911bc95 bump 2020-05-26 12:08:58 +02:00
Kukks
ce7a70bb99 fix logs styling 2020-05-26 12:08:50 +02:00
Kukks
9b4fb02241 bump dynamic linq and set JObject type on receive webhook 2020-05-26 12:05:07 +02:00
Kukks
aa68a90224 Allow a webhook receive trigger to accept any http method 2020-05-26 12:04:36 +02:00
Kukks
236f416fc6 do not show individual actions or allow creation of them anymore 2020-05-26 10:46:12 +02:00
Kukks
36fbd57209 fix api stuff 2020-05-26 10:32:19 +02:00
Kukks
28c2bac049 fix badge styling 2020-05-26 09:57:56 +02:00
Kukks
2c6ace2a95 set basic auth to correct scheme 2020-05-25 09:13:51 +02:00
Kukks
a9d5a2fadb fix webhook receive 2020-05-24 15:54:17 +02:00
Kukks
215d311113 wip 2020-05-24 15:54:17 +02:00
Andrew Camilleri
e598cc10d2
Update config.yml 2020-05-14 17:40:26 +02:00
Dennis Reimann
25383e196b
Use relative asset links in docs (#61)
This way [Vuepress can handle them correctly](https://vuepress.vuejs.org/guide/assets.html#relative-urls) and they work on GitHub too.
2020-05-08 15:27:06 +02:00
Andrew Camilleri
d5c84fa491
Update config.yml 2020-04-30 20:03:13 +02:00
Andrew Camilleri
05b64186fb
Update config.yml 2020-04-30 19:15:11 +02:00
Andrew Camilleri
a75c275c10
test docs trigger 2020-04-30 19:14:00 +02:00
britttttk
1ca2119138
Add demo guide for Transmuter email receipt preset (#52)
* Add ticket demo guide

* Add Presets to index.md doc

* move new section to readme

Co-authored-by: Kukks <evilkukka@gmail.com>
2020-04-28 09:50:38 +02:00
Andrew Camilleri
0138d9712b
Merge pull request #58 from Eskyee/patch-1
fixed typo missing dot and whitespace
2020-04-26 13:20:26 +02:00
Esky33
19db0dff46
fixed typo missing dot and whitespace 2020-04-26 11:59:07 +01:00
Andrew Camilleri
f21a4ac701
Merge pull request #56 from 2pac1/master
Update README.md
2020-04-15 17:06:53 +02:00
2pac1
0295dd1e87
Update README.md 2020-04-15 16:54:32 +02:00
Kukks
1293f03182 Make basic auth always an api 2020-04-06 08:40:16 +02:00
Kukks
d56356d2f3 make the scheme use the same one as cookie 2020-04-05 16:53:05 +02:00
Kukks
ded2313463 recipe actions api 2020-04-05 10:28:14 +02:00
Kukks
e7c48e2db7 Make add action group a post action 2020-04-05 10:18:59 +02:00
Kukks
ddfc647300 newtonsoft json for mvc 2020-04-04 14:32:10 +02:00
Kukks
5902da4212 Add ReDoc and swagger 2020-04-04 14:27:27 +02:00
Kukks
774007e5c7 fix authorization for api 2020-04-04 14:05:13 +02:00
Kukks
c47efa0b43 Recipes API 2020-04-02 15:27:06 +02:00
Kukks
c8fee0e18f make cookie default scheme 2020-04-02 14:28:55 +02:00
Kukks
c3b73c7e4d fix auth selector 2020-04-02 13:43:40 +02:00
Kukks
0e7a7a5d70 Add role claims when authenticated 2020-04-02 12:05:14 +02:00
Kukks
08a3329eff Add Basic Auth option 2020-04-02 11:58:52 +02:00
Kukks
5b29c62fc6 Cleanup Identity pages 2020-04-02 11:58:46 +02:00
Kukks
8ad099bcce Add Blob to User 2020-04-02 10:51:10 +02:00
Kukks
2fba3da43e fixes #54 2020-03-10 12:35:13 +01:00
Kukks
9649294bbf fix issue with operators plugin 2020-03-02 12:56:08 +01:00
Kukks
c555df3054 bump 2020-02-27 11:38:05 +01:00
Kukks
78ca88b030 add fingerprint and acc key path to wallet gen helper 2020-02-27 11:37:07 +01:00
Kukks
7ffaa89f55 move and update docs 2020-02-27 11:13:54 +01:00
Kukks
d80adaada3 add qr code for 2fa
fixes #43
2020-02-27 09:09:14 +01:00
Andrew Camilleri
2c7f7ef780
Merge pull request #51 from britttttk/email-preset
Fix smtp dropdown
2020-02-26 20:29:34 +01:00
Britt Kelly
e1d82f0350 Fix smtp dropdown 2020-02-19 20:26:27 -07:00
Kukks
4dd0b4450c fix more ef core issues 2020-02-17 17:18:59 +01:00
Kukks
e258d6b19f fix dockerfiles 2020-02-14 12:23:25 +01:00
Kukks
be14704843 bump 2020-02-14 12:10:07 +01:00
Kukks
4744d574e4 fix #48 2020-02-14 12:06:20 +01:00
Kukks
a085305b4b fix #49 2020-02-14 12:04:41 +01:00
Kukks
f09094087c fix bug with logs 2020-02-14 11:48:54 +01:00
Kukks
9b950cf46d Make payment forwarder use nbx wallet generator 2020-02-14 11:24:38 +01:00
Kukks
bebefb5f48 Fix Wallet generator to use proper derived xpubs 2020-02-14 11:13:46 +01:00
Kukks
079b67f421 Merge branch '3.0' 2020-01-22 20:50:49 +01:00
Kukks
4efeddf080 fix docker 2020-01-22 17:22:19 +01:00
Kukks
951ae61b25 remove direct embedded resources! 2020-01-22 17:22:19 +01:00
Kukks
58946b1427 fix view loading 2020-01-22 17:22:19 +01:00
Kukks
a2eb4d0194 bump some more packages 2020-01-22 17:22:19 +01:00
Kukks
33fde4b51f switch to dotnetcoreplugins 2020-01-22 17:22:19 +01:00
Kukks
a82ea4221b fix some ef core breaking changes 2020-01-22 17:22:19 +01:00
Kukks
19858588db package bumps 2020-01-22 17:22:18 +01:00
Kukks
de1a6a0adc switch to correct dynamic.core lib 2020-01-22 17:22:18 +01:00
Kukks
f55e390859 consolidate docker builds for .net core 3.1 2020-01-22 17:22:18 +01:00
Kukks
ba945afb3a switching to 3.1 2020-01-22 17:22:18 +01:00
Kukks
9efb53b93a Use a base class for Ids in Entity models to make sure Id is autogenerated 2020-01-22 17:22:18 +01:00
Kukks
c108c4e9b2 fix presets plugin 2020-01-22 17:22:18 +01:00
Kukks
f705b2c187 final fixes 2020-01-22 17:22:18 +01:00
Kukks
875248fc23 fixes allaround 2020-01-22 17:22:18 +01:00
Kukks
d05a1a5c3c start migrating to net core 3.0 and 2.1 netstandard 2020-01-22 17:22:18 +01:00
Andrew Camilleri
a91aa41173 Merge pull request #47 from britttttk/preset-percent
Calculate percent before parse
2020-01-22 13:44:26 +01:00
Kukks
987b2d4169 make amount formula simpler 2020-01-20 14:10:19 +01:00
Kukks
41672156c4 bump version 2019-12-18 14:55:41 +01:00
Kukks
eb61e7c08f remove messy hack for json interpolation 2019-12-18 14:54:44 +01:00
Kukks
6ee85be74a fix forwarder preset + make the interpolation system modular 2019-12-17 17:08:49 +01:00
Kukks
7589e94202 bump 2019-12-13 15:18:09 +01:00
Kukks
df946a441a fix get payments from invoice by allowing any payment type option and not breaking when multiple same cryptocode payment types are avaialble 2019-12-13 15:08:37 +01:00
Kukks
80c4ad5189 make action view clearer of params 2019-12-13 15:07:45 +01:00
Kukks
9f64f17b49 fix and simplify fiat preset 2019-12-13 15:06:36 +01:00
Kukks
205151a83d Add tests for interpolation helper 2019-12-13 15:05:58 +01:00
Kukks
12c599e5cb bump to 45 2019-12-13 11:11:00 +01:00
Kukks
ba491bfccd fixes 2019-12-13 11:10:10 +01:00
Kukks
9d9c61c9f2 revert app name in data protection change 2019-12-13 10:48:22 +01:00
Kukks
b067106fcf Add create link 2019-12-13 10:48:08 +01:00
Kukks
fc6158db3b bump in app version 2019-12-12 16:43:06 +01:00
Kukks
6bc7024244 create fiat market sell preset 2019-12-11 17:38:32 +01:00
Kukks
67f39bf73d fix build 2019-12-10 13:21:47 +01:00
Kukks
cf06bb1a7c fix cookie and data protection 2019-12-10 13:17:04 +01:00
Kukks
d653113492 better logging and start handling some errors 2019-12-10 12:55:15 +01:00
Kukks
61a8daa1b5 fix preset text 2019-12-10 11:54:50 +01:00
Kukks
834d87e8ae add btcpay email receipt preset 2019-12-10 11:26:23 +01:00
Kukks
c85c03e8e7 fix onion link 2019-12-09 19:54:48 +01:00
Kukks
5464d508e4 support sub path app 2019-12-09 16:10:03 +01:00
Andrew Camilleri
037d280c6b
Merge pull request #45 from britttttk/patch-1
Improve export command
2019-12-02 08:00:15 +01:00
britttttk
739d303956
remove extra space 2019-12-01 13:18:38 -07:00
britttttk
b725d48860
Add transmuter to existing env vars in docs 2019-12-01 13:15:41 -07:00
britttttk
c357f67b46
Improve export command
Add instructions for adding transmuter to existing environment variables.
2019-11-30 18:28:15 -07:00
Andrew Camilleri
8dcc42d867
Merge pull request #44 from pavlenex/master
Add how to deploy instructions
2019-11-30 12:04:30 +01:00
pavlenex
6d7b95e089 Add how to deploy instructions 2019-11-30 11:08:29 +01:00
Kukks
85924bd786 bump nbitcoin & remove DerivFactoryProvider 2019-11-19 18:30:21 +01:00
Kukks
4a8c73e805 attempt fix for onion url 2019-11-19 17:08:24 +01:00
Kukks
5a2586e597 bump version 2019-11-11 06:44:29 +01:00
Kukks
a65ef7e340 bump exchangesharp 2019-11-11 06:43:31 +01:00
Kukks
0b58b61b07 remove docker layer caching because CircleCI business team sucks 2019-11-04 09:05:55 +01:00
Kukks
cd207bc0dc Move email tester logic to smtp service instead of send email action. 2019-11-04 08:53:17 +01:00
Kukks
9ef7b0b2b5 add test email for smtp
closes #42
2019-11-02 09:34:05 +01:00
Kukks
b725299b1d fix stray ascii 2019-09-30 13:23:08 +02:00
Kukks
12c1ea59b3 fix nbx wallet balance viewer 2019-09-30 11:22:50 +02:00
Kukks
62d6494cb0 bump 2019-09-29 18:34:31 +02:00
Kukks
2e46509b10 use correct nertwork 2019-09-29 17:45:37 +02:00
Kukks
b9979f7bfd fixes #29 2019-09-29 17:44:31 +02:00
Kukks
48b2084f54 fixes #38 2019-09-29 15:11:05 +02:00
Kukks
52f6f5c4ba add datetime picker ui 2019-09-29 15:05:31 +02:00
Kukks
240ff51c7e fixes #28 2019-09-27 18:46:28 +02:00
Kukks
ea6cfaab25 use xpub not xpriv fixes #32 2019-09-27 18:31:12 +02:00
Kukks
40d561f199 remove confusing addresses closes #35 2019-09-27 18:28:13 +02:00
Kukks
9d9b099a31 add different viewmode for recipe list
closes #39
2019-09-27 18:26:27 +02:00
Kukks
bb83f20fb2 fix viewing logs issue with previous recipe action 2019-09-27 16:05:23 +02:00
Kukks
6e8db6282a recipe logs should not block action deletion/changes 2019-09-27 15:32:02 +02:00
Kukks
1e3b66ca6d allow actions and action groups to be collapsed 2019-09-27 12:20:21 +02:00
Kukks
f3f9a07cb0 Tor hidden service extension
closes #40
2019-09-27 12:08:13 +02:00
Kukks
b20b149b1c discourage search engines, closes #31 2019-09-27 11:29:43 +02:00
Kukks
d9f672804c make sure to set ishtml in edit view on load 2019-08-20 15:04:48 +02:00
Kukks
b2e5b14dd6 bump 2019-08-19 17:05:12 +02:00
Kukks
6638105e69 fix db col encryption for dev env 2019-08-19 17:04:53 +02:00
Kukks
36878ec7c0 make send email able to send HTML body 2019-08-19 17:04:43 +02:00
Kukks
afa340ccb8 fix condition action 2019-08-19 17:04:10 +02:00
Kukks
0c8d9bd136 remove redundant validation summary 2019-08-19 16:18:31 +02:00
Kukks
88786b5fe5 update version not package version 2019-08-19 16:11:08 +02:00
Kukks
f9f1d2d2f3 bump v 2019-08-19 15:42:55 +02:00
Kukks
090bbd464a fix condition action edit view 2019-08-19 15:11:23 +02:00
Andrew Camilleri
061fab086b move fee submission to before destinations added 2019-06-18 12:22:41 +02:00
Andrew Camilleri
d5ec6f7e0d make trigger execution source not wait for full cycle to finish properly 2019-06-18 10:48:03 +02:00
Andrew Camilleri
dff978f556 make db encryption optional until we add more settings for it 2019-06-18 10:47:37 +02:00
Kukks
fda441854f add more logs to nbx wallet display 2019-06-13 21:24:50 +02:00
Kukks
c725444347 Allow configuration of fee in send transaction action 2019-06-13 21:23:21 +02:00
Kukks
a90a44cb19 fix get balance view model issue 2019-06-11 17:56:35 +02:00
Kukks
d0442693b2 add log for balance failure 2019-06-11 17:50:21 +02:00
Kukks
cfc6e95012 bump to 26 2019-06-10 21:04:05 +02:00
Kukks
58cbbfa5f8 fixes #25 2019-06-10 21:03:59 +02:00
Kukks
7a755d356b closes #26 2019-06-10 21:03:45 +02:00
Kukks
ee63b10f96 add alpha warning 2019-06-10 21:03:07 +02:00
Kukks
4e3b832395 allow cloning of recipe through UI and fix bug with cloning recipes that are linked to external services 2019-06-10 15:00:06 +02:00
Kukks
e44094ceb1 move clone recipe to manager instead of action to reuse in UI 2019-06-10 13:11:09 +02:00
Kukks
d6cd796ae5 add more logging toplace order action 2019-06-10 13:03:23 +02:00
Kukks
d043f0bf88 redo status change trigger to handle any usecase 2019-06-10 12:54:39 +02:00
Kukks
f66e971c0a Reduce microsoft specific logs 2019-06-10 09:29:42 +02:00
Kukks
a5a34f3681 make sure there is no conflict with older version 2019-06-08 20:59:07 +02:00
Kukks
f41f6efe4c fixes #24 2019-06-08 20:53:04 +02:00
Kukks
5adc78eede fixes #23 2019-06-08 20:30:02 +02:00
Kukks
5f3edaa0eb Verify Externalservice trigger matches the recipe trigger's
fixes #22
2019-06-08 20:05:44 +02:00
Kukks
1a9f972dab do not use p2sh in preset if crypto is not available 2019-05-26 19:32:30 +02:00
Kukks
c0c6083069 add dropdowns for exchange balances fixes #19 2019-05-26 19:14:26 +02:00
Kukks
afc65f0f15 make nbx view tidier 2019-05-26 18:49:28 +02:00
Kukks
5118869219 fix build 2019-05-26 15:50:50 +02:00
Kukks
bd937ae9e3 fix nbx wallet view 2019-05-26 15:03:35 +02:00
Kukks
2f5f53531e fix js bug 2019-05-26 14:34:06 +02:00
Kukks
1921f19e66 improve exchange service UX 2019-05-26 14:14:20 +02:00
Kukks
87dd78f3ab fixes #15 2019-05-25 17:08:12 +02:00
Kukks
8bad5e1105 fix tests 2019-05-25 16:45:58 +02:00
Kukks
a17697a011 closes #15 2019-05-24 15:03:13 +02:00
Kukks
dcd79d104b closes #14 2019-05-24 14:17:24 +02:00
Kukks
3b92f4b4ed closes #16 2019-05-24 13:14:53 +02:00
Kukks
b996143abc closes #20 2019-05-24 13:14:37 +02:00
Kukks
07e0ccd284 cleanup homepage 2019-05-24 13:09:58 +02:00
Kukks
0549ecd94c fix condition edit view 2019-05-24 13:06:11 +02:00
Kukks
cc6065d7df fix anime 2019-05-19 11:06:58 +02:00
Kukks
832eec1400 lighter anime js 2019-05-19 09:26:38 +02:00
Kukks
651b2bf181 small ux fixes for forwarder preset 2019-05-19 08:14:20 +02:00
Kukks
2e626e448b remove duplicate error message 2019-05-19 07:58:08 +02:00
Kukks
2b66b0b26b include jquery scripts 2019-05-19 07:52:32 +02:00
Kukks
dca7bd02c5 use new logo 2019-05-18 17:13:47 +02:00
Kukks
9bd4864e4a fix compile error 2019-05-18 16:15:43 +02:00
Kukks
94377e964c bump deps 2019-05-18 16:15:12 +02:00
Kukks
2cb8e9c02b protect preset endpoint 2019-05-08 13:45:31 +02:00
Kukks
d8e43af4a4 bump nbitcoin and lightning lib 2019-05-08 13:45:22 +02:00
Kukks
76d52a4be2 improve homepage 2019-05-07 15:39:01 +02:00
Kukks
51f7724f3c use local svgs 2019-05-07 13:27:27 +02:00
Kukks
fe37f28713 make homepage pretty 2019-05-07 13:23:50 +02:00
Kukks
17684a2a44 remove chmod in docker 2019-05-07 09:30:50 +02:00
Kukks
2b284733a6 add in payment forwarder preset 2019-05-07 09:12:07 +02:00
Kukks
19babb809b payment forwarder backend code 2019-05-06 22:18:30 +02:00
Kukks
624dd99654 start working on presets 2019-05-06 17:29:58 +02:00
Kukks
110d287e94 Allow extensions to define global json converters 2019-05-06 15:00:47 +02:00
Kukks
caee4b70f5 fix ToJson func 2019-05-06 14:31:17 +02:00
Kukks
104c2074df work on adding funcs to interpolator 2019-05-05 19:15:43 +02:00
Kukks
53ea6b9b76 fix ln node service info no populated 2019-05-05 15:47:53 +02:00
Kukks
6da6edd27f fix case specific bug in nbx summary checker 2019-05-05 15:45:43 +02:00
Kukks
0100da72f0 bump nbitcoin and nbx 2019-05-05 15:45:21 +02:00
Kukks
fb75d110f5 more tests 2019-05-05 13:55:39 +02:00
Kukks
e02637c850 18% coverage 2019-05-03 19:44:14 +02:00
Kukks
80d753db54 more base test code 2019-05-02 13:08:11 +02:00
Kukks
3340ca6cde more test code 2019-05-02 12:45:33 +02:00
Kukks
a7432b868a cleanup redundant code 2019-05-01 13:07:12 +02:00
Kukks
caf0f6b691 test coverage 17% coverage 2019-05-01 13:03:21 +02:00
Kukks
409f3a01c0 test coverage 9% - painful days ahead 2019-04-30 16:06:27 +02:00
Kukks
797863aa79 more test fx 2019-04-30 15:00:45 +02:00
Kukks
6314829956 fix failing tests and start creating test framework 2019-04-30 14:23:06 +02:00
Kukks
4b60896aa4 switch to extcore again (plugins not working yet) 2019-04-29 17:13:28 +02:00
Kukks
5486680082 fix model issue 2019-04-29 15:27:31 +02:00
Kukks
ae5895b4ab add ln payment trigger view 2019-04-29 15:25:47 +02:00
Kukks
9d6ead2d82 Add Received Lightning Payment trigger 2019-04-29 15:22:57 +02:00
Kukks
e0f9348b5f comment out psbt actions 2019-04-29 12:18:08 +02:00
Kukks
ebd8d94663 rename to user recipes 2019-04-24 14:41:43 +02:00
Kukks
a10fdf5c28 use specific view fore recipe view 2019-04-24 14:36:40 +02:00
Kukks
6890e272cb update dockerfiles 2019-04-24 14:34:12 +02:00
Kukks
da8a2cea85 fix role check 2019-04-24 14:26:10 +02:00
Kukks
01d994fe85 cleanup mess 2019-04-24 14:24:51 +02:00
Kukks
1ae11a2c8d Merge remote-tracking branch 'origin/master' 2019-04-21 19:50:51 +02:00
Kukks
6d0d1c1658 initial work for admin ui 2019-04-21 19:50:48 +02:00
Andrew Camilleri
c499f60e11
Update README.md 2019-04-21 19:46:08 +02:00
Andrew Camilleri
fed70fbd3b
Merge pull request #6 from knocte/patch-1
docs/index.md: trivial fixes
2019-04-21 19:45:18 +02:00
Andres G. Aragoneses
8f1bc8bec9
docs/index.md: trivial fixes
Fix a header, a typo and a missing word.
2019-04-22 01:28:58 +08:00
Kukks
d07b0fec89 improve helper performance with cache and allow dictionaries and Lists too 2019-04-21 16:03:09 +02:00
Kukks
ffb5b3d937 display array types in template helper 2019-04-21 14:51:27 +02:00
Kukks
d474983185 entrypoint change 2019-04-21 10:38:12 +02:00
Kukks
917035cf16 fix config 2019-04-18 12:37:15 +02:00
Kukks
1a50156c96 switch from , to ; in nbx crypto options 2019-04-18 12:36:47 +02:00
Kukks
2936db7e1f Add conditions action 2019-04-16 10:33:59 +02:00
Kukks
e75cb999fb add get invoice action 2019-04-16 10:08:16 +02:00
Kukks
c548c0721e fix second booboo 2019-04-16 09:52:42 +02:00
Kukks
4bdfc9d89c fix booboo 2019-04-16 09:51:53 +02:00
Kukks
e097e3619e make recipe action helper display all available data in an action group 2019-04-16 09:47:13 +02:00
Kukks
0c82b52a70 switch to jsonconvert as it handles wider variety of json types 2019-04-16 09:36:57 +02:00
Kukks
27453f7010 remove weird log logic (im looking at you rockstardev) 2019-04-16 09:36:22 +02:00
Kukks
cdd4099f8d add get invoice payments 2019-04-16 08:58:10 +02:00
Kukks
ce1facbb16 uncertain fix for recipe logs deletion 2019-04-15 18:05:23 +02:00
Kukks
e1c6a3f295 fix send email action view 2019-04-14 18:59:15 +02:00
Kukks
0be41bb278 fixes to prevent issues with json serialization 2019-04-14 18:53:23 +02:00
Kukks
11a3512372 give warning on executed recipe group deletion 2019-04-14 16:33:46 +02:00
Kukks
a7b522f3eb make external service validation clearer 2019-04-14 16:27:59 +02:00
Kukks
52c39903a7 fix action group list styling 2019-04-14 16:27:08 +02:00
Kukks
7d05b1c224 fix action template helper from crashing 2019-04-14 16:26:59 +02:00
Kukks
29e43daaab fix external service security check 2019-04-14 10:56:53 +02:00
Kukks
a8d2de67c5 optimzie linq 2019-04-12 15:23:15 +02:00
Kukks
ffab3f8ef5 fix recipe removal after invocation change 2019-04-12 14:31:00 +02:00
Kukks
9ac8101a9b dynamic service marker trigger 2019-04-12 14:20:49 +02:00
Kukks
a9eaa83a3b fix typo 2019-04-12 14:20:06 +02:00
Kukks
c3b7fd8ecc fix sqlite migrations issues 2019-04-12 14:19:12 +02:00
Kukks
31a95c3815 bump nbitcoin and reflact socketfactory changes from btcpay 2019-04-05 10:38:04 +02:00
Kukks
193c544c5e dynamic external service to resolve external services by running actions 2019-04-04 19:12:48 +02:00
Kukks
033dbd84e6 add dynamic service extensions 2019-04-04 15:31:55 +02:00
Kukks
9cb0a7f08a start operators plugin + choose numeric value action 2019-04-03 19:38:20 +02:00
Kukks
686b6b7639 add get exchange rate action 2019-04-03 18:08:29 +02:00
Kukks
e598d5aa21 remove some compiler warnings 2019-04-03 10:14:13 +02:00
Kukks
c291dee93c prevent external service misuse 2019-04-03 10:07:09 +02:00
Kukks
a875cebba6 add check exchange balance action 2019-04-02 14:20:07 +02:00
Kukks
22892b3de7 add get balance on exchange action 2019-04-02 13:21:22 +02:00
Kukks
90c8fce73e rough (probably non-working ) impl to sign psbt action 2019-04-02 12:44:02 +02:00
Kukks
d76f88a85d move wallet helper to wallet service 2019-04-02 09:27:15 +02:00
Kukks
9c9eb05fef get ln channels action 2019-04-01 16:32:31 +02:00
Kukks
911ea78395 add more comparers for balance checks 2019-04-01 16:17:23 +02:00
Kukks
8eaf9a3b51 fix get recipes bug 2019-04-01 16:13:10 +02:00
Kukks
cf6f45e700 fix entrypoint 2019-04-01 15:44:03 +02:00
Kukks
46ae42c52d debump to 2.2.2 2019-04-01 15:35:40 +02:00
Kukks
980c18bb65 fix logger issue 2019-04-01 15:35:32 +02:00
Kukks
3bc2ca969f roll back net core bumps 2019-04-01 15:26:01 +02:00
Kukks
73ad01dab2 update docker tags 2019-04-01 15:10:27 +02:00
Kukks
b4b93a84ee update dockerfiles 2019-04-01 14:56:14 +02:00
Kukks
4b4a6491e9 extension dir config 2019-04-01 14:13:40 +02:00
Kukks
083496678a bump everything and cleanup ln sockets logic 2019-04-01 11:45:50 +02:00
Kukks
ddaeebb708 clean up migration sqlite code 2019-04-01 11:15:13 +02:00
Kukks
260dfa5636 refactor config loading 2019-04-01 10:28:15 +02:00
Kukks
b7b09e3fbb cascade elete recipe logs on actions 2019-03-31 19:57:45 +02:00
Kukks
c0cccad5de prep to separate data protection path from sqlite dir and also start work on allowing postgres 2019-03-31 19:57:33 +02:00
Kukks
d895b2fc76 Get Balance & Create PSBT actions 2019-03-31 19:57:05 +02:00
Kukks
acf5e78afe refactor NBXplorer plugin to have a wallet external service to remove duplicate code 2019-03-31 14:49:08 +02:00
Kukks
05cf5c3feb fix responsive tables 2019-03-30 18:40:17 +01:00
Kukks
e7c64f90b3 do not expose sensitive conn string for ln node 2019-03-30 17:10:46 +01:00
Kukks
b12ebb5ad0 optimzie recipe logs page peformance with paging 2019-03-30 16:59:24 +01:00
Kukks
004b3a5466 fix infinite loop bug 2019-03-29 18:03:49 +01:00
Kukks
c43dddbed7 reduce log spam 2019-03-29 18:03:39 +01:00
Kukks
70853a36c6 make tables responsive 2019-03-29 18:03:26 +01:00
Kukks
2f3c479fd2 make balance trigger execute more often 2019-03-29 18:03:13 +01:00
Kukks
4f9c7b54e7 format 2019-03-29 14:56:23 +01:00
Kukks
e9e5f9ab4a add ActionData accessor 2019-03-29 14:46:54 +01:00
Kukks
5e212c7ef5 refactoring wallet spending +adding in fees subtraction from output 2019-03-29 14:41:25 +01:00
Kukks
d4ef1a46b7 fix error 2019-03-29 11:13:21 +01:00
Kukks
f3a25735de handle fee assignment to a txout 2019-03-29 11:12:10 +01:00
Kukks
ba274e126c fix styling of recipe page 2019-03-29 09:45:58 +01:00
Kukks
b032ca55b4 improve wallet generate page 2019-03-29 09:00:00 +01:00
Kukks
59b79645b7 fix menu item format 2019-03-28 16:26:42 +01:00
Kukks
9fd2875431 add wallet page 2019-03-28 16:26:13 +01:00
Kukks
d1902741bb fix card margins 2019-03-28 13:08:18 +01:00
Kukks
77b171984c persist dp keys close to db files for now 2019-03-28 11:46:37 +01:00
Kukks
71699f01a1 introcuce marker for encrypted columns 2019-03-28 11:27:54 +01:00
Kukks
b46bfdad9c add encryption to json data in db columns 2019-03-28 11:18:46 +01:00
Kukks
30bfd4627a allow multiple keys for signing tx 2019-03-28 11:17:09 +01:00
Kukks
efe08046a0 do not sign with dud key 2019-03-27 20:23:44 +01:00
Kukks
2333ddcd3a fix incorrect flag in send tx action 2019-03-27 19:51:48 +01:00
Kukks
632a5d531e heavier action handler refactoring 2019-03-27 19:41:17 +01:00
Kukks
29725809aa fix interpolation issue 2019-03-27 19:21:09 +01:00
Kukks
e11925ece5 nbxplorer serialization issues 2019-03-27 17:26:41 +01:00
Kukks
78fb747ed5 still fixing 2019-03-27 15:45:39 +01:00
Kukks
822e6b2222 complicated system make for complicate bugs 2019-03-27 15:35:08 +01:00
Kukks
eee2491f06 fix generate address action 2019-03-26 16:34:06 +01:00
Kukks
ed8088d821 fix bug in send transaction action handler 2019-03-25 13:53:06 +01:00
Kukks
c2554a5315 generate next address for xpub action 2019-03-25 13:52:52 +01:00
Kukks
245019f5e7 get ln deposit address action 2019-03-23 13:16:16 +01:00
Kukks
ca83dee7d4 get ln info action 2019-03-22 12:15:31 +01:00
Kukks
182c228eb8 Open ln channel action 2019-03-22 11:41:30 +01:00
Kukks
fcad602e55 connect to ln node action 2019-03-22 10:56:14 +01:00
Kukks
b703e986e0 add pay bolt 11 action 2019-03-22 10:27:04 +01:00
Kukks
02b366fd14 fix action group action creation bug 2019-03-22 09:33:50 +01:00
Kukks
64f26486d2 create bolt invoice action 2019-03-21 17:36:11 +01:00
Kukks
2826702913 add lightning external service 2019-03-21 14:34:23 +01:00
Kukks
56351c6ee4 fix typo 2019-03-19 16:10:31 +01:00
Kukks
861d8db6d0 fix recipe action group ordering 2019-03-19 14:59:26 +01:00
Kukks
22b572cb46 allow actions in group to display type data to help with templates 2019-03-19 14:40:12 +01:00
Kukks
79e5b955a0 return data from action result and allow usage in subsequent actions in groups 2019-03-19 11:10:54 +01:00
Kukks
43240af3e1 fix ordering of actions in action groups 2019-03-19 09:36:52 +01:00
Kukks
7d0f3ddf4d fix recipe cloning for action groups 2019-03-19 09:36:33 +01:00
Kukks
ede60391fa migration replace( sqlite sucks) 2019-03-18 13:11:29 +01:00
Kukks
a56d4ea6eb integrate recipe action group to UI 2019-03-18 13:11:01 +01:00
Andrew Camilleri
ff4d501fda start work on recipe action groups concept 2019-03-17 10:50:36 +01:00
Kukks
46b303bfc6 Merge remote-tracking branch 'origin/master' 2019-03-16 17:27:06 +01:00
Kukks
c8b528d305 broadcast transaction action 2019-03-16 17:27:02 +01:00
rockstardev
93693bdfb0 reversing ordering of recipe logs 2019-03-15 11:30:38 -05:00
rockstardev
b62c0fa38f newlines influence display of PosData, restoring format 2019-03-15 11:05:47 -05:00
rockstardev
8a67cdb029 ui tweaks for more streamlined demo 2019-03-13 17:10:56 -05:00
rockstardev
65073be373 setting MarketSymbol for exchange orders 2019-03-13 16:25:36 -05:00
rockstardev
b9c47fd5d2 small ui fixes 2019-03-13 16:00:05 -05:00
rockstardev
740c4f65ae supporting different named labels in BtcPayserver access token list 2019-03-13 15:36:08 -05:00
Kukks
f554719c13 wip arm 2019-03-13 14:20:43 +01:00
Kukks
5141ef626c entrypoint for arm fix 2019-03-13 14:09:37 +01:00
Kukks
647019932e check 2019-03-13 13:33:05 +01:00
Kukks
b5266d3a58 fix arm maybe 2019-03-13 13:25:44 +01:00
Kukks
e904599e39 fix docker entrypoint sh permissions 2019-03-13 13:11:43 +01:00
Kukks
04138d19fd fix dockerfile refs 2019-03-13 10:08:10 +01:00
Kukks
3d15d29767 fix tags regex 2019-03-13 09:44:19 +01:00
Kukks
3cbd9841ef comment out tests for now 2019-03-13 09:38:34 +01:00
Kukks
3abad1a1d2 add circleci 2019-03-13 09:34:42 +01:00
Kukks
fb731f0a55 improve ux for editing btcpay service closes #2 2019-03-13 08:26:32 +01:00
Kukks
99cbd4b471 fix missing using statements in views 2019-03-13 08:01:03 +01:00
Kukks
a09ad29671 lost commit 2019-03-13 07:53:54 +01:00
Kukks
10db2436bf make docker use sh entrypoint 2019-03-12 16:06:13 +01:00
Kukks
03e0c619f5 more changes and fixes 2019-03-12 14:38:26 +01:00
Kukks
9744d6c7f3 deriv format helper 2019-03-12 14:26:08 +01:00
Kukks
3d40773770 bug fixes across thingies 2019-03-12 14:24:57 +01:00
Kukks
707b1c5611 more field descriptors 2019-03-12 14:12:24 +01:00
Kukks
3e8aee2bb3 clarify override url better 2019-03-12 10:31:01 +01:00
Kukks
a78fe80086 better exchange external service validation 2019-03-12 08:32:04 +01:00
Kukks
79834f00b7 add better form descriptors 2019-03-12 08:31:52 +01:00
Kukks
b4ebeaf5e8 rename hax 2 2019-03-11 17:14:56 +01:00
Kukks
b01674b18e rename hax 2019-03-11 17:14:30 +01:00
Kukks
c2f21cf47e disable plugin upload for now 2019-03-11 17:14:03 +01:00
Kukks
ec313c3e17 use default cookie for local setup and fix switchcasee 2019-03-11 16:58:52 +01:00
Kukks
eec9cae7a7 fixes for prod and docker deploys 2019-03-11 16:49:46 +01:00
Kukks
0d50244447 add extensions folder to ignore 2019-03-11 11:37:21 +01:00
Kukks
172d35e147 fix shared types loading 2019-03-11 11:37:00 +01:00
Kukks
f008ee0c6c rename things 2019-03-11 10:54:28 +01:00
Kukks
95d7f23517 plugin system that can read application parts 2019-03-11 10:52:05 +01:00
Kukks
fa4ca60d15 FIX!! 2019-03-10 19:51:13 +01:00
Kukks
456b1fcfc3 switch to razor class libs and recreate issue in dev env 2019-03-10 18:35:40 +01:00
Kukks
91103187e5 remove dependency on extcore as a test 2019-03-09 23:14:19 +01:00
Kukks
c09cf4d88f Revert "temporary workaround.."
This reverts commit cbe68e746f.
2019-03-09 22:27:49 +01:00
Kukks
cbe68e746f temporary workaround.. 2019-03-09 22:03:35 +01:00
Kukks
caf914e15b test 2019-03-07 16:07:14 +01:00
Kukks
4ac82a6c17 equalize extensions page 2019-03-07 15:59:19 +01:00
Kukks
5dc61e88f9 Balance trigger 2019-03-07 15:43:52 +01:00
Kukks
d307609289 prep work for balance triggers 2019-03-07 11:28:42 +01:00
Kukks
baca381c82 serialize with explorer client in both ways 2019-03-07 09:31:55 +01:00
Kukks
066ec410ca small fix 2019-03-07 09:22:39 +01:00
Kukks
14581ff166 docker now loads but login is still fucky fucky 5 dolla 2019-03-07 08:45:25 +01:00
Kukks
bb8da26237 cleanup 2019-03-07 08:44:40 +01:00
Kukks
14b2b81957 clean up serializer 2019-03-07 08:26:36 +01:00
Kukks
7358258b6f more fixes in tx trigger handling 2019-03-07 08:23:42 +01:00
Kukks
83cfc181e0 clean up serializer 2019-03-07 08:21:53 +01:00
Kukks
70241b47aa attempt to fix stack overflow issue with Nbx model serialization 2019-03-07 08:00:38 +01:00
Kukks
f71c7390cd add missing confirmations input on nbx tx trigger 2019-03-06 15:32:32 +01:00
Kukks
9deaa92b50 [very experimental] minimum confirmations for tx detection code 2019-03-05 21:51:39 +01:00
Kukks
11c66a9272 track in nbx 2019-03-04 16:55:29 +01:00
Kukks
36a70f759d add address validation 2019-03-04 16:37:16 +01:00
Kukks
f9b5f25001 REALLY fix nbxplorer integration 2019-03-04 16:33:49 +01:00
Kukks
07993ed526 more fixes 2019-03-04 15:42:31 +01:00
Kukks
82d7a06913 fixes on nbxplorer 2019-03-04 15:00:46 +01:00
Kukks
6db2a4bdf9 transaction triggers 2019-03-04 14:24:37 +01:00
Kukks
5de3d96fc7 start work on new transaction triggers for address and xpubs 2019-03-03 11:03:24 +01:00
Kukks
2e6b2ba520 small changes 2019-03-03 08:41:49 +01:00
Kukks
ba053703f5 NBXplorer initial integration 2019-03-02 17:10:12 +01:00
Kukks
c3c9b8eab1 fixes for remote installs 2019-03-01 16:38:24 +01:00
Kukks
cffb4bc7bf prep system to install extensions remotely 2019-03-01 16:30:54 +01:00
Kukks
994be72697 Allow extensions to manipulate main menus 2019-03-01 16:30:34 +01:00
Kukks
2b4cb2229c comment out email related features in identity 2019-03-01 15:39:27 +01:00
Kukks
0fea721f14 add roles to identity 2019-03-01 15:39:13 +01:00
Kukks
6d48c5f3d1 manual extension installer 2019-03-01 15:38:49 +01:00
Kukks
278a356dfc fix manage ui 2019-03-01 13:54:40 +01:00
Kukks
574fa7f240 add identity ui in proj 2019-03-01 13:51:09 +01:00
Kukks
d297154cd5 fixes and unit tests (10% coverage mark) 2019-03-01 12:58:00 +01:00
Kukks
a375734dda styling posadata better 2019-03-01 11:04:27 +01:00
Kukks
199f5a90d6 fix formatting 2019-03-01 10:48:20 +01:00
Kukks
a97d550e8c interpolate more 2019-03-01 08:07:43 +01:00
Kukks
7685f76239 interpolate data in webhook actions 2019-03-01 08:07:03 +01:00
Kukks
896615675a move extensions specific tests to own porject 2019-03-01 08:06:51 +01:00
Kukks
7bd76f541d change syntax for interpolation in actions to not conflict with json 2019-03-01 08:06:29 +01:00
Kukks
9581d74330 fix stack overflow bug! 2019-02-28 19:30:24 +01:00
Kukks
0977d58228 Merge remote-tracking branch 'origin/master' 2019-02-28 18:39:31 +01:00
Kukks
2227eaa0f6 failsafes when used extensions are unloaded 2019-02-28 18:39:26 +01:00
Kukks
ea2dc4001e failsafes when used extensions are unloaded 2019-02-28 18:36:41 +01:00
663 changed files with 81570 additions and 1379 deletions

132
.circleci/config.yml Normal file
View File

@ -0,0 +1,132 @@
version: 2
jobs:
build:
machine:
docker_layer_caching: false
steps:
- checkout
# publish jobs require $DOCKERHUB_REPO, $DOCKERHUB_USER, $DOCKERHUB_PASS defined
publish_docker_linuxamd64:
machine:
docker_layer_caching: false
steps:
- checkout
- run:
command: |
LATEST_TAG=${CIRCLE_TAG:1} #trim v from tag
if [ -z "$LATEST_TAG" ]
then
LATEST_TAG="latest"
fi
#
sudo docker build --pull -t $DOCKERHUB_REPO:$LATEST_TAG-amd64 -f Dockerfiles/amd64.Dockerfile .
sudo docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS
sudo docker push $DOCKERHUB_REPO:$LATEST_TAG-amd64
publish_docker_linuxarm32:
machine:
docker_layer_caching: false
steps:
- checkout
- run:
command: |
sudo docker run --rm --privileged multiarch/qemu-user-static:register --reset
LATEST_TAG=${CIRCLE_TAG:1} #trim v from tag
if [ -z "$LATEST_TAG" ]
then
LATEST_TAG="latest"
fi
#
sudo docker build --pull -t $DOCKERHUB_REPO:$LATEST_TAG-arm32v7 -f Dockerfiles/arm32v7.Dockerfile .
sudo docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS
sudo docker push $DOCKERHUB_REPO:$LATEST_TAG-arm32v7
publish_docker_linuxarm64:
machine:
docker_layer_caching: false
steps:
- checkout
- run:
command: |
sudo docker run --rm --privileged multiarch/qemu-user-static:register --reset
LATEST_TAG=${CIRCLE_TAG:1} #trim v from tag
if [ -z "$LATEST_TAG" ]
then
LATEST_TAG="latest"
fi
#
sudo docker build --pull -t $DOCKERHUB_REPO:$LATEST_TAG-arm64v8 -f Dockerfiles/arm64v8.Dockerfile .
sudo docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS
sudo docker push $DOCKERHUB_REPO:$LATEST_TAG-arm64v8
publish_docker_multiarch:
machine:
enabled: true
image: circleci/classic:201808-01
steps:
- run:
command: |
# Turn on Experimental features
sudo mkdir $HOME/.docker
sudo sh -c 'echo "{ \"experimental\": \"enabled\" }" >> $HOME/.docker/config.json'
#
sudo docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS
#
LATEST_TAG=${CIRCLE_TAG:1} #trim v from tag
if [ -z "$LATEST_TAG" ]
then
LATEST_TAG="latest"
fi
sudo docker manifest create --amend $DOCKERHUB_REPO:$LATEST_TAG $DOCKERHUB_REPO:$LATEST_TAG-amd64 $DOCKERHUB_REPO:$LATEST_TAG-arm32v7 $DOCKERHUB_REPO:$LATEST_TAG-arm64v8
sudo docker manifest annotate $DOCKERHUB_REPO:$LATEST_TAG $DOCKERHUB_REPO:$LATEST_TAG-amd64 --os linux --arch amd64
sudo docker manifest annotate $DOCKERHUB_REPO:$LATEST_TAG $DOCKERHUB_REPO:$LATEST_TAG-arm32v7 --os linux --arch arm --variant v7
sudo docker manifest annotate $DOCKERHUB_REPO:$LATEST_TAG $DOCKERHUB_REPO:$LATEST_TAG-arm64v8 --os linux --arch arm64 --variant v8
sudo docker manifest push $DOCKERHUB_REPO:$LATEST_TAG -p
trigger_docs_build:
machine:
enabled: true
image: circleci/classic:201808-01
steps:
- run:
command: |
curl -X POST -H "Authorization: token $GH_PAT" -H "Accept: application/vnd.github.everest-preview+json" -H "Content-Type: application/json" https://api.github.com/repos/btcpayserver/btcpayserver-doc/dispatches --data '{"event_type": "build_docs"}'
workflows:
version: 2
publish:
jobs:
- trigger_docs_build:
filters:
branches:
only: master
# only act on version tags
tags:
only: /v[0-9]+(\.[0-9]+)*/
- publish_docker_linuxamd64:
filters:
# ignore any commit on any branch by default
branches:
only: master
# only act on version tags
tags:
only: /v[0-9]+(\.[0-9]+)*/
- publish_docker_linuxarm32:
filters:
branches:
only: master
tags:
only: /v[0-9]+(\.[0-9]+)*/
- publish_docker_linuxarm64:
filters:
branches:
only: master
tags:
only: /v[0-9]+(\.[0-9]+)*/
- publish_docker_multiarch:
requires:
- publish_docker_linuxamd64
- publish_docker_linuxarm32
- publish_docker_linuxarm64
filters:
branches:
only: master
tags:
only: /v[0-9]+(\.[0-9]+)*/

5
.gitignore vendored
View File

@ -299,3 +299,8 @@ BtcTransmuter/mydb.db
BtcTransmuter\.Extension\.BtcPayServer/obj/Debug/netcoreapp2\.2/
BtcTransmuter\.Extension\.BtcPayServer/obj/
BtcTransmuter/Extensions/
/BtcTransmuter/Extensions/
/BtcTransmuter/mydb.db_old
dest

View File

@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
<OutputType>Library</OutputType>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\BtcTransmuter.Abstractions\BtcTransmuter.Abstractions.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,16 @@
using Microsoft.Extensions.Configuration;
namespace BTCTransmuter.Extension.Tor.Configuration
{
public class BTCTransmuterTorOptions
{
public string TorrcFile { get; }
public string TransmuterHiddenServiceName { get; }
public BTCTransmuterTorOptions(IConfiguration configuration)
{
TorrcFile = configuration.GetValue<string>(nameof(TorrcFile), null);
TransmuterHiddenServiceName = configuration.GetValue(nameof(TransmuterHiddenServiceName), "BTCTransmuter");
}
}
}

View File

@ -0,0 +1,44 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using BTCTransmuter.Extension.Tor.Configuration;
using BTCTransmuter.Extension.Tor.Services;
using Microsoft.Extensions.Hosting;
namespace BTCTransmuter.Extension.Tor.HostedServices
{
public class TorServicesHostedService : IHostedService
{
private readonly BTCTransmuterTorOptions _btcTransmuterTorOptions;
private readonly TorServices _torServices;
public TorServicesHostedService(BTCTransmuterTorOptions btcTransmuterTorOptions, TorServices torServices)
{
_btcTransmuterTorOptions = btcTransmuterTorOptions;
_torServices = torServices;
}
public Task StartAsync(CancellationToken cancellationToken)
{
if (!string.IsNullOrEmpty(_btcTransmuterTorOptions.TorrcFile))
{
_ = ContinuouslyMonitorTorServices(cancellationToken);
}
return Task.CompletedTask;
}
private async Task ContinuouslyMonitorTorServices(CancellationToken cancellationToken)
{
while (!cancellationToken.IsCancellationRequested)
{
_torServices.Refresh();
await Task.Delay(TimeSpan.FromMinutes(2), cancellationToken);
}
}
public Task StopAsync(CancellationToken cancellationToken)
{
return Task.CompletedTask;
}
}
}

View File

@ -0,0 +1,9 @@
namespace BTCTransmuter.Extension.Tor.Models
{
public class TorService
{
public string Name { get; set; }
public string OnionHost { get; set; }
public int VirtualPort { get; set; }
}
}

View File

@ -0,0 +1,91 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using BTCTransmuter.Extension.Tor.Configuration;
using BTCTransmuter.Extension.Tor.Models;
using Microsoft.Extensions.Logging;
namespace BTCTransmuter.Extension.Tor.Services
{
public class TorServices
{
private readonly BTCTransmuterTorOptions _transmuterTorOptions;
private readonly ILogger<TorServices> _logger;
public TorServices(BTCTransmuterTorOptions transmuterTorOptions, ILogger<TorServices> logger)
{
_transmuterTorOptions = transmuterTorOptions;
_logger = logger;
}
public TorService[] Services { get; internal set; } = Array.Empty<TorService>();
public TorService TransmuterTorService
{
get
{
if (string.IsNullOrEmpty(_transmuterTorOptions.TransmuterHiddenServiceName))
{
return null;
}
return Services.SingleOrDefault(service =>
service.Name.Equals(_transmuterTorOptions.TransmuterHiddenServiceName,
StringComparison.InvariantCultureIgnoreCase));
}
}
internal void Refresh()
{
if (string.IsNullOrEmpty(_transmuterTorOptions.TorrcFile) || !File.Exists(_transmuterTorOptions.TorrcFile))
{
if (!string.IsNullOrEmpty(_transmuterTorOptions.TorrcFile))
_logger.LogWarning("Torrc file is not found");
Services = Array.Empty<TorService>();
return;
}
List<TorService> result = new List<TorService>();
try
{
var torrcContent = File.ReadAllText(_transmuterTorOptions.TorrcFile);
if (!Torrc.TryParse(torrcContent, out var torrc))
{
_logger.LogWarning("Torrc file could not be parsed");
Services = Array.Empty<TorService>();
return;
}
var services = torrc.ServiceDirectories.SelectMany(d => d.ServicePorts.Select(p => (Directory: new DirectoryInfo(d.DirectoryPath), VirtualPort: p.VirtualPort)))
.Select(d => (ServiceName: d.Directory.Name,
ReadingLines: System.IO.File.ReadAllLines(Path.Combine(d.Directory.FullName, "hostname")),
VirtualPort: d.VirtualPort))
.ToArray();
foreach (var service in services)
{
try
{
var onionHost = (service.ReadingLines)[0].Trim();
var torService = new TorService()
{
Name = service.ServiceName,
OnionHost = $"http://{onionHost}",
VirtualPort = service.VirtualPort
};
result.Add(torService);
}
catch (Exception ex)
{
_logger.LogWarning(ex, $"Error while reading hidden service {service.ServiceName} configuration");
}
}
}
catch (Exception ex)
{
_logger.LogWarning(ex, $"Error while reading torrc file");
}
Services = result.ToArray();
}
}
}

View File

@ -0,0 +1,98 @@
using System;
using System.Collections.Generic;
using System.Net;
using System.Text;
namespace BTCTransmuter.Extension.Tor.Services
{
public class Torrc
{
public static bool TryParse(string str, out Torrc value)
{
value = null;
List<HiddenServiceDir> serviceDirectories = new List<HiddenServiceDir>();
var lines = str.Split(new char[] { '\n' });
HiddenServiceDir currentDirectory = null;
foreach (var line in lines)
{
if (HiddenServiceDir.TryParse(line, out var dir))
{
serviceDirectories.Add(dir);
currentDirectory = dir;
}
else if (HiddenServicePortDefinition.TryParse(line, out var portDef) && currentDirectory != null)
{
currentDirectory.ServicePorts.Add(portDef);
}
}
value = new Torrc() { ServiceDirectories = serviceDirectories };
return true;
}
public List<HiddenServiceDir> ServiceDirectories { get; set; } = new List<HiddenServiceDir>();
public override string ToString()
{
StringBuilder builder = new StringBuilder();
foreach(var serviceDir in ServiceDirectories)
{
builder.AppendLine(serviceDir.ToString());
foreach (var port in serviceDir.ServicePorts)
builder.AppendLine(port.ToString());
}
return builder.ToString();
}
}
public class HiddenServiceDir
{
public static bool TryParse(string str, out HiddenServiceDir serviceDir)
{
serviceDir = null;
if (!str.Trim().StartsWith("HiddenServiceDir ", StringComparison.OrdinalIgnoreCase))
return false;
var parts = str.Split(new char[] { ' ', '\t' }, StringSplitOptions.None);
if (parts.Length != 2)
return false;
serviceDir = new HiddenServiceDir() { DirectoryPath = parts[1].Trim() };
return true;
}
public string DirectoryPath { get; set; }
public List<HiddenServicePortDefinition> ServicePorts { get; set; } = new List<HiddenServicePortDefinition>();
public override string ToString()
{
return $"HiddenServiceDir {DirectoryPath}";
}
}
public class HiddenServicePortDefinition
{
public static bool TryParse(string str, out HiddenServicePortDefinition portDefinition)
{
portDefinition = null;
if (!str.Trim().StartsWith("HiddenServicePort ", StringComparison.OrdinalIgnoreCase))
return false;
var parts = str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
if (parts.Length != 3)
return false;
if (!int.TryParse(parts[1].Trim(), out int virtualPort))
return false;
var addressPort = parts[2].Trim().Split(new []{':'}, StringSplitOptions.RemoveEmptyEntries);
if (addressPort.Length != 2)
return false;
if (!int.TryParse(addressPort[1].Trim(), out int port))
return false;
if (!IPAddress.TryParse(addressPort[0].Trim(), out IPAddress address))
return false;
portDefinition = new HiddenServicePortDefinition() { VirtualPort = virtualPort, Endpoint = new IPEndPoint(address, port) };
return true;
}
public int VirtualPort { get; set; }
public IPEndPoint Endpoint { get; set; }
public override string ToString()
{
return $"HiddenServicePort {VirtualPort} {Endpoint}";
}
}
}

View File

@ -0,0 +1,22 @@
using System;
using BtcTransmuter.Abstractions.Extensions;
using BTCTransmuter.Extension.Tor.Configuration;
using BTCTransmuter.Extension.Tor.Services;
using Microsoft.Extensions.DependencyInjection;
namespace BTCTransmuter.Extension.Tor
{
public class TorBtcTransmuterExtension : BtcTransmuterExtension
{
public override string Name => "Tor Plugin";
public override string Description => "Allows you to access Transmuter over Tor";
public override string MenuPartial => "TorOnionLinkPartial";
public override void Execute(IServiceCollection serviceCollection)
{
serviceCollection.AddSingleton<BTCTransmuterTorOptions>();
serviceCollection.AddSingleton<TorServices>();
base.Execute(serviceCollection);
}
}
}

View File

@ -0,0 +1,7 @@
@inject BTCTransmuter.Extension.Tor.Services.TorServices TorServices
@if (TorServices.TransmuterTorService != null)
{
<li class="nav-item">
<a href="@TorServices.TransmuterTorService.OnionHost" class="nav-link">Onion</a>
</li>
}

View File

@ -1,17 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AssemblyName>BtcTransmuter.Extension.Timer</AssemblyName>
<RootNamespace>BtcTransmuter.Extension.Timer</RootNamespace>
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="Styles\**;Views\**;Scripts\**" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BtcTransmuter.Abstractions\BtcTransmuter.Abstractions.csproj" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Timer\EditData.cshtml" />
</ItemGroup>
</Project>

View File

@ -1,8 +1,30 @@
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace BtcTransmuter.Abstractions.Actions
{
public class ActionHandlerResult
{
public bool Executed { get; set; }
public string Result { get; set; }
public object Data { get; protected set; }
public virtual string DataJson => JsonConvert.SerializeObject(Data);
}
// public class StringJsonResult
// {
// public StringJsonResult()
// {
// }
//
// public StringJsonResult(string value)
// {
// Value = value;
// }
//
// public string Value { get; set; }
// }
}

View File

@ -1,4 +1,7 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using BtcTransmuter.Abstractions.ExternalServices;
using BtcTransmuter.Abstractions.Recipes;
using BtcTransmuter.Data.Entities;
using Microsoft.AspNetCore.Authorization;
@ -8,21 +11,31 @@ using Microsoft.Extensions.Caching.Memory;
namespace BtcTransmuter.Abstractions.Actions
{
public interface IActionViewModel
{
string RecipeId { get; set; }
string RecipeActionIdInGroupBeforeThisOne { get; set; }
}
[Authorize]
public abstract class BaseActionController<TViewModel, TRecipeActionData> : Controller
where TViewModel : TRecipeActionData
where TViewModel : TRecipeActionData, IActionViewModel
{
private readonly IMemoryCache _memoryCache;
protected readonly UserManager<User> _userManager;
protected readonly IRecipeManager _recipeManager;
private readonly IExternalServiceManager _externalServiceManager;
private string RecipeActionIdInGroupBeforeThisOne;
protected BaseActionController(IMemoryCache memoryCache,
UserManager<User> userManager,
IRecipeManager recipeManager)
IRecipeManager recipeManager,
IExternalServiceManager externalServiceManager)
{
_memoryCache = memoryCache;
_userManager = userManager;
_recipeManager = recipeManager;
_externalServiceManager = externalServiceManager;
}
[HttpGet("{identifier}")]
@ -34,7 +47,11 @@ namespace BtcTransmuter.Abstractions.Actions
return result.Error;
}
return View(await BuildViewModel(result.Data));
var vm = await BuildViewModel(result.Data);
vm.RecipeId = result.Data.RecipeId;
vm.RecipeActionIdInGroupBeforeThisOne = RecipeActionIdInGroupBeforeThisOne;
return View(vm);
}
[HttpPost("{identifier}")]
@ -50,8 +67,22 @@ namespace BtcTransmuter.Abstractions.Actions
if (modelResult.showViewModel != null)
{
modelResult.showViewModel.RecipeId = result.Data.RecipeId;
modelResult.showViewModel.RecipeActionIdInGroupBeforeThisOne = RecipeActionIdInGroupBeforeThisOne;
return View(modelResult.showViewModel);
}
if (!string.IsNullOrEmpty(modelResult.ToSave.ExternalServiceId))
{
var externalService= await _externalServiceManager.GetExternalServiceData(
modelResult.ToSave.ExternalServiceId,
GetUserId());
if (externalService == null)
{
return BadRequest("what you tryin to pull bro");
}
modelResult.ToSave.ExternalService = externalService;
}
await _recipeManager.AddOrUpdateRecipeAction(modelResult.ToSave);
@ -63,6 +94,7 @@ namespace BtcTransmuter.Abstractions.Actions
}
protected abstract Task<TViewModel> BuildViewModel(RecipeAction recipeAction);
protected abstract Task<(RecipeAction ToSave, TViewModel showViewModel)> BuildModel(
TViewModel viewModel, RecipeAction mainModel);
@ -86,6 +118,31 @@ namespace BtcTransmuter.Abstractions.Actions
}), null);
}
if (!string.IsNullOrEmpty(data.RecipeActionGroupId))
{
var recipeActionGroup = recipe.RecipeActionGroups.Single(group =>
group.Id.Equals(data.RecipeActionGroupId, StringComparison.InvariantCultureIgnoreCase));
var actions = recipeActionGroup.RecipeActions.OrderBy(action => action.Order);
var matched = actions.Select((action, i) => (action, i))
.Where(tuple => tuple.Item1.ActionId == data.Id);
var index = matched.Any()
? actions.Select((action, i) => (action, i))
.Where(tuple => tuple.Item1.ActionId == data.Id)
.Select(tuple => tuple.Item2)
.FirstOrDefault()
: -1;
if (index == -1 && actions.Any())
{
RecipeActionIdInGroupBeforeThisOne = actions.Last().Id;
}
else if (index > 0)
{
RecipeActionIdInGroupBeforeThisOne = actions.ElementAt(index - 1).Id;
}
}
return (null, data);
}

View File

@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
@ -8,10 +10,11 @@ using BtcTransmuter.Data.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json.Linq;
namespace BtcTransmuter.Abstractions.Actions
{
public abstract class BaseActionHandler<TActionData> : IActionHandler, IActionDescriptor
public abstract class BaseActionHandler<TActionData, TActionResultData> : IActionHandler, IActionDescriptor
{
public abstract string ActionId { get; }
public abstract string Name { get; }
@ -19,6 +22,8 @@ namespace BtcTransmuter.Abstractions.Actions
public abstract string ViewPartial { get; }
public abstract string ControllerName { get; }
public Type ActionResultDataType => typeof(TActionResultData);
public virtual Task<IActionResult> EditData(RecipeAction data)
{
@ -40,44 +45,29 @@ namespace BtcTransmuter.Abstractions.Actions
}
}
protected abstract Task<bool> CanExecute(object triggerData, RecipeAction recipeAction);
public async Task<ActionHandlerResult> Execute(object triggerData, RecipeAction recipeAction)
public virtual Task<bool> CanExecute(Dictionary<string, (object data, string json)> data, RecipeAction recipeAction)
{
if (await CanExecute(triggerData, recipeAction))
{
return await Execute(triggerData, recipeAction, recipeAction.Get<TActionData>());
}
return new ActionHandlerResult()
{
Executed = false
};
return Task.FromResult(recipeAction.ActionId == ActionId);
}
protected abstract Task<ActionHandlerResult> Execute(object triggerData, RecipeAction recipeAction,
public Task<ActionHandlerResult> Execute(Dictionary<string, (object data, string json)> data, RecipeAction recipeAction)
{
return Execute(data.ToDictionary(pair => pair.Key, pair => pair.Value.data), recipeAction);
}
public async Task<ActionHandlerResult> Execute(Dictionary<string, object> data, RecipeAction recipeAction)
{
return await Execute(data, recipeAction, recipeAction.Get<TActionData>());
}
protected abstract Task<TypedActionHandlerResult<TActionResultData>> Execute(Dictionary<string, object> data, RecipeAction recipeAction,
TActionData actionData);
/// <summary>
/// https://dotnetfiddle.net/MoqJFk
/// </summary>
protected static string InterpolateString(string value, object @object)
protected static string InterpolateString(string value, Dictionary<string, object> data)
{
try
{
return Regex.Replace(value, @"{(.+?)}",
match =>
{
var p = Expression.Parameter(@object.GetType(), "TriggerData");
var e = System.Linq.Dynamic.DynamicExpression.ParseLambda(new[] {p}, null,
match.Groups[1].Value);
return (e.Compile().DynamicInvoke(@object) ?? "").ToString();
});
}
catch (Exception e)
{
return value;
}
return InterpolationHelper.InterpolateString(value, data);
}
}
}

View File

@ -1,3 +1,4 @@
using System;
using System.Threading.Tasks;
using BtcTransmuter.Data.Entities;
using Microsoft.AspNetCore.Mvc;
@ -11,6 +12,7 @@ namespace BtcTransmuter.Abstractions.Actions
string Description { get; }
string ViewPartial { get; }
Type ActionResultDataType { get; }
Task<IActionResult> EditData(RecipeAction data);
}
}

View File

@ -1,3 +1,4 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using BtcTransmuter.Data;
using BtcTransmuter.Data.Entities;
@ -6,6 +7,9 @@ namespace BtcTransmuter.Abstractions.Actions
{
public interface IActionDispatcher
{
Task Dispatch(object triggerData, RecipeAction recipeAction);
Task<IEnumerable<ActionHandlerResult>> Dispatch(Dictionary<string, (object data, string json)> triggerData,
RecipeAction recipeAction);
Task Dispatch(Dictionary<string, (object data, string json)> data, RecipeActionGroup recipeActionGroup);
}
}

View File

@ -1,12 +1,17 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using BtcTransmuter.Data;
using BtcTransmuter.Data.Entities;
namespace BtcTransmuter.Abstractions.Actions
{
public interface IActionHandler
{
Task<ActionHandlerResult> Execute(object triggerData, RecipeAction recipeAction);
Type ActionResultDataType { get; }
Task<ActionHandlerResult> Execute(Dictionary<string, (object data, string json)> data,
RecipeAction recipeAction);
Task<bool> CanExecute(Dictionary<string, (object data, string json)> data, RecipeAction recipeAction);
}
}

View File

@ -0,0 +1,11 @@
namespace BtcTransmuter.Abstractions.Actions
{
public class TypedActionHandlerResult<T>: ActionHandlerResult
{
public T TypedData
{
get => (T) Data;
set => Data = value;
}
}
}

View File

@ -1,14 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ExtCore.Mvc.Infrastructure" Version="4.0.0" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="2.2.0" />
<PackageReference Include="NetCore.AutoRegisterDi" Version="1.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="wilx.System.Linq.Dynamic.Core" Version="2.1.0" />
<PackageReference Include="McMaster.NETCore.Plugins" Version="1.3.0" />
<PackageReference Include="McMaster.NETCore.Plugins.Mvc" Version="1.3.0" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="3.1.4" />
<PackageReference Include="NetCore.AutoRegisterDi" Version="2.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.1.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BtcTransmuter.Data\BtcTransmuter.Data.csproj" />

View File

@ -0,0 +1,8 @@
namespace BtcTransmuter
{
public enum DatabaseType
{
Sqlite,
Postgres
}
}

View File

@ -0,0 +1,15 @@
using System;
namespace BtcTransmuter
{
public interface IBtcTransmuterOptions
{
string ExtensionsDir { get; set; }
string DatabaseConnectionString { get; set; }
string DataProtectionDir { get; set; }
DatabaseType DatabaseType { get; set; }
bool UseDatabaseColumnEncryption { get; set; }
bool DisableInternalAuth { get; set; }
Uri BTCPayAuthServer { get; set; }
}
}

View File

@ -1,27 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using BtcTransmuter.Abstractions.Actions;
using BtcTransmuter.Abstractions.ExternalServices;
using BtcTransmuter.Abstractions.Helpers;
using BtcTransmuter.Abstractions.Triggers;
using ExtCore.Infrastructure;
using ExtCore.Infrastructure.Actions;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using NetCore.AutoRegisterDi;
using Newtonsoft.Json;
namespace BtcTransmuter.Abstractions.Extensions
{
public abstract class BtcTransmuterExtension : ExtensionBase, IConfigureAction, IConfigureServicesAction
public abstract class BtcTransmuterExtension: IExtension
{
int IConfigureServicesAction.Priority => Priority;
int IConfigureAction.Priority => Priority;
protected abstract int Priority { get; }
public string HeaderPartial { get; }
public abstract string Name { get; }
public virtual string Version => GetType().Assembly.GetName().Version.ToString();
public virtual string Description { get; } = string.Empty;
public virtual string Authors { get; } = string.Empty;
public virtual string HeaderPartial { get; }
public virtual string MenuPartial { get; }
public virtual IEnumerable<JsonConverter> JsonConverters { get; set; }
public IEnumerable<IActionDescriptor> Actions => GetInstancesOfTypeInOurAssembly<IActionDescriptor>();
public IEnumerable<ITriggerDescriptor> Triggers => GetInstancesOfTypeInOurAssembly<ITriggerDescriptor>();
@ -34,7 +38,12 @@ namespace BtcTransmuter.Abstractions.Extensions
{
}
public virtual void Execute(IServiceCollection serviceCollection, IServiceProvider serviceProvider)
public void Execute(IServiceCollection serviceCollection, IServiceProvider serviceProvider)
{
Execute(serviceCollection);
}
public virtual void Execute(IServiceCollection serviceCollection)
{
RegisterInstances(serviceCollection, new Type[]
{
@ -42,13 +51,17 @@ namespace BtcTransmuter.Abstractions.Extensions
typeof(IActionHandler),
typeof(ITriggerDescriptor),
typeof(ITriggerHandler),
typeof(IHostedService),
typeof(IExternalServiceDescriptor),
typeof(TransmuterInterpolationTypeProvider),
});
RegisterInstances(serviceCollection, new Type[]
{
typeof(IHostedService)
}, ServiceLifetime.Singleton);
serviceCollection.AddSingleton(this);
}
private void RegisterInstances(IServiceCollection serviceCollection, Type[] validTypes)
private void RegisterInstances(IServiceCollection serviceCollection, Type[] validTypes, ServiceLifetime serviceLifetime = ServiceLifetime.Transient)
{
var types = serviceCollection
.RegisterAssemblyPublicNonGenericClasses(Assembly.GetAssembly(GetType()))
@ -61,14 +74,16 @@ namespace BtcTransmuter.Abstractions.Extensions
foreach (var type in types.TypesToConsider)
{
Console.WriteLine($"Registering {type.FullName}");
}
types.AsPublicImplementedInterfaces();
types.AsPublicImplementedInterfaces(serviceLifetime);
}
private IEnumerable<T> GetInstancesOfTypeInOurAssembly<T>() where T : class
{
return ExtensionManager.GetInstances<T>(assembly => assembly == Assembly.GetAssembly(GetType()));
return Assembly.GetAssembly(GetType()).GetTypes().Where(t => typeof(T).IsAssignableFrom(t) && !t.IsAbstract)
.Select(type => (T) Activator.CreateInstance(type, new object[0]));
}
}
}

View File

@ -0,0 +1,57 @@
using System.Collections.Generic;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace BtcTransmuter.Abstractions.Extensions
{
public static class ControllerExtensions
{
public static bool IsApi(this Controller controller)
{
return controller.HttpContext.IsApi();
}
public static bool IsApi(this HttpContext context)
{
if (context.Items.TryGetValue("API", out var val))
{
return val is true;
}
return false;
}
public static void SetIsApi(this HttpContext context, bool val)
{
context.Items.TryAdd("API", val);
}
public static IActionResult ViewOrJson<T>(this Controller controller, string viewName, T payload)
{
if (controller.IsApi())
{
return controller.Json(payload);
}
return controller.View(viewName, payload);
}
public static IActionResult ViewOrJson<T>(this Controller controller, T payload)
{
if (controller.IsApi())
{
return controller.Json(payload);
}
return controller.View(payload);
}
public static IActionResult ViewOrBadRequest<T>(this Controller controller, T payload, bool usePayloadInBadRequest = false)
{
if (controller.IsApi())
{
return usePayloadInBadRequest ? controller.BadRequest(payload) : controller.BadRequest(controller.ModelState);
}
return controller.View(payload);
}
}
}

View File

@ -0,0 +1,14 @@
using System.Collections.Generic;
namespace BtcTransmuter.Abstractions.Extensions
{
public static class EnumerableExtensions
{
public static HashSet<T> ToHashSet<T>(
this IEnumerable<T> source,
IEqualityComparer<T> comparer = null)
{
return new HashSet<T>(source, comparer);
}
}
}

View File

@ -0,0 +1,10 @@
namespace BtcTransmuter.Abstractions.Extensions
{
public interface IExtension
{
string Name { get; }
string Version { get; }
string Description { get; }
string Authors { get; }
}
}

View File

@ -0,0 +1,15 @@
using Microsoft.AspNetCore.Mvc.ModelBinding;
namespace BtcTransmuter.Abstractions.Extensions
{
public static class ModelStateExtensions
{
public static void AddModelError<TModel>(this TModel source,
string name,
string message,
ModelStateDictionary modelState)
{
modelState.AddModelError(name, message);
}
}
}

View File

@ -0,0 +1,16 @@
using Microsoft.AspNetCore.Http;
namespace BtcTransmuter.Abstractions.Extensions
{
public static class RequestExtensions
{
public static string GetAbsoluteRoot(this HttpRequest request)
{
return string.Concat(
request.Scheme,
"://",
request.Host.ToUriComponent(),
request.PathBase.ToUriComponent());
}
}
}

View File

@ -0,0 +1,17 @@
using System;
namespace BtcTransmuter.Abstractions.Extensions
{
public static class StringExtensions
{
public static string TrimEnd(this string input, string suffixToRemove,
StringComparison comparisonType) {
if (input != null && suffixToRemove != null
&& input.EndsWith(suffixToRemove, comparisonType)) {
return input.Substring(0, input.Length - suffixToRemove.Length);
}
else return input;
}
}
}

View File

@ -19,15 +19,15 @@ namespace BtcTransmuter.Abstractions.ExternalServices
public abstract string Name { get; }
public abstract string Description { get; }
public abstract string ViewPartial { get; }
protected abstract string ControllerName { get; }
public abstract string ControllerName { get; }
public T GetData()
public virtual T GetData()
{
return _data.Get<T>();
}
public void SetData(T data)
public virtual void SetData(T data)
{
_data.Set(data);
}

View File

@ -18,7 +18,8 @@ namespace BtcTransmuter.Abstractions.ExternalServices
private readonly UserManager<User> _userManager;
private readonly IMemoryCache _memoryCache;
protected BaseExternalServiceController(IExternalServiceManager externalServiceManager, UserManager<User> userManager,
protected BaseExternalServiceController(IExternalServiceManager externalServiceManager,
UserManager<User> userManager,
IMemoryCache memoryCache)
{
_externalServiceManager = externalServiceManager;
@ -34,11 +35,12 @@ namespace BtcTransmuter.Abstractions.ExternalServices
{
return result.Error;
}
return View(await BuildViewModel(result.Data));
}
protected abstract Task<TViewModel> BuildViewModel(ExternalServiceData data);
protected abstract Task<(ExternalServiceData ToSave, TViewModel showViewModel)> BuildModel(
TViewModel viewModel, ExternalServiceData mainModel);
@ -67,7 +69,7 @@ namespace BtcTransmuter.Abstractions.ExternalServices
statusMessage = "Data updated"
});
}
private async Task<(IActionResult Error, ExternalServiceData Data )> GetExternalServiceData(string identifier)
{
ExternalServiceData data = null;
@ -80,6 +82,7 @@ namespace BtcTransmuter.Abstractions.ExternalServices
statusMessage = "Error:Data could not be found or data session expired"
}), null);
}
if (data.UserId != _userManager.GetUserId(User))
{
return (RedirectToAction("GetServices", "ExternalServices", new
@ -110,5 +113,11 @@ namespace BtcTransmuter.Abstractions.ExternalServices
return (null, data);
}
protected async Task<bool> IsAdmin()
{
var user = await _userManager.GetUserAsync(User);
return user!= null && await _userManager.IsInRoleAsync(user, "Admin");
}
}
}

View File

@ -0,0 +1,78 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Linq.Dynamic.Core.CustomTypeProviders;
using System.Linq.Expressions;
using System.Text.RegularExpressions;
using BtcTransmuter.Abstractions.Extensions;
using Newtonsoft.Json;
namespace BtcTransmuter.Abstractions.Helpers
{
public class TransmuterInterpolationTypeProvider : DefaultDynamicLinqCustomTypeProvider
{
private readonly Type[] _types;
public TransmuterInterpolationTypeProvider(params Type[] types)
{
_types = types;
}
public override HashSet<Type> GetCustomTypes()
{
return _types.ToHashSet();
}
}
public sealed class InterpolationTypeProvider : DefaultDynamicLinqCustomTypeProvider {
private readonly IEnumerable<DefaultDynamicLinqCustomTypeProvider> _typeProviders;
public InterpolationTypeProvider(IEnumerable<TransmuterInterpolationTypeProvider> typeProviders)
{
_typeProviders = typeProviders;
ParsingConfig.Default.CustomTypeProvider = this;
}
public override HashSet<Type> GetCustomTypes()
{
return _typeProviders.SelectMany(provider => provider.GetCustomTypes()).ToHashSet();
}
}
public static class InterpolationHelper
{
/// <summary>
/// https://dotnetfiddle.net/MoqJFk
/// </summary>
public static string InterpolateString(string value, Dictionary<string, object> data)
{
try
{
var parameterExpressions =
data.Select(pair => Expression.Parameter(pair.Value.GetType(), pair.Key)).ToList();
return Regex.Replace(value, @"{{(.+?)}}",
match =>
{
var processed = match.Groups[1].Value;
try
{
var e = DynamicExpressionParser.ParseLambda(parameterExpressions.ToArray(), null,
processed);
return (e.Compile().DynamicInvoke(data.Values.ToArray()) ?? "").ToString();
}
catch (Exception)
{
return processed;
}
});
}
catch (Exception)
{
return value;
}
}
}
}

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace BtcTransmuter.Abstractions.Helpers
@ -10,14 +11,14 @@ namespace BtcTransmuter.Abstractions.Helpers
public static ICollection<ValidationResult> Validate<T>(string data)
{
try
{
var parsedData = JObject.Parse(data).ToObject<T>();
{
var parsedData = JsonConvert.DeserializeObject<T>(data);
var vc = new ValidationContext(parsedData);
var result = new List<ValidationResult>();
Validator.TryValidateObject(data, vc, result);
return result;
}
catch (Exception e)
catch (Exception)
{
return new List<ValidationResult>()
{
@ -25,8 +26,5 @@ namespace BtcTransmuter.Abstractions.Helpers
};
}
}
}
}

View File

@ -0,0 +1,8 @@
namespace BtcTransmuter.Abstractions.Models
{
public class OrderBy<T>
{
public T Field { get; set; }
public OrderDirection Direction { get; set; }
}
}

View File

@ -0,0 +1,8 @@
namespace BtcTransmuter.Abstractions.Models
{
public enum OrderDirection
{
Ascending,
Descending
}
}

View File

@ -1,4 +1,4 @@
using System.Collections;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using BtcTransmuter.Data;
@ -9,15 +9,22 @@ namespace BtcTransmuter.Abstractions.Recipes
public interface IRecipeManager
{
Task<IEnumerable<Recipe>> GetRecipes(RecipesQuery query);
Task<IEnumerable<RecipeInvocation>> GetRecipeInvocations(RecipeInvocationsQuery query);
Task AddOrUpdateRecipe(Recipe recipe);
Task AddOrUpdateRecipeTrigger(RecipeTrigger trigger);
Task AddOrUpdateRecipeTriggers(IEnumerable<RecipeTrigger> triggers);
Task AddOrUpdateRecipeAction(RecipeAction action);
Task AddRecipeActionGroup(RecipeActionGroup recipeActionGroup);
Task ReorderRecipeActionGroupActions(string recipeActionGroupId, Dictionary<string, int> actionsOrder);
Task RemoveRecipe(string id);
Task<Recipe> GetRecipe(string id, string userId = null);
Task AddRecipeInvocation(RecipeInvocation invocation);
Task RemoveRecipeAction(string recipeActionId);
Task RemoveRecipeTrigger(string recipeTriggerId);
Task RemoveRecipeActionGroup(string recipeActionGroupId);
Task<string> GetRecipeName(string recipeId);
Task<Recipe> CloneRecipe(string recipeId, bool enable, string newName = null);
}
}

View File

@ -0,0 +1,18 @@
using BtcTransmuter.Abstractions.Models;
namespace BtcTransmuter.Abstractions.Recipes
{
public class RecipeInvocationsQuery
{
public string RecipeId { get; set; }
public int Skip { get; set; }
public int Take { get; set; }
public OrderBy<RecipeInvocationsQueryOrderBy> OrderBy { get; set; }
public enum RecipeInvocationsQueryOrderBy
{
Timestamp
}
}
}

View File

@ -4,8 +4,10 @@ namespace BtcTransmuter.Abstractions.Recipes
{
public bool? Enabled { get; set; }
public string RecipeTriggerId { get; set; }
public string TriggerId { get; set; }
public string UserId { get; set; }
public string RecipeId { get; set; }
public bool IncludeRecipeInvocations { get; set; }
}
}

View File

@ -0,0 +1,10 @@
using System.Threading.Tasks;
namespace BtcTransmuter.Abstractions.Settings
{
public interface ISettingsManager
{
Task<T> GetSettings<T>(string key);
Task SaveSettings<T>(string key,T settings);
}
}

View File

@ -1,4 +1,5 @@
using System.Threading.Tasks;
using BtcTransmuter.Abstractions.ExternalServices;
using BtcTransmuter.Abstractions.Recipes;
using BtcTransmuter.Data.Entities;
using Microsoft.AspNetCore.Authorization;
@ -14,15 +15,18 @@ namespace BtcTransmuter.Abstractions.Triggers
{
private readonly IRecipeManager _recipeManager;
private readonly UserManager<User> _userManager;
private readonly IExternalServiceManager _externalServiceManager;
private readonly IMemoryCache _memoryCache;
protected BaseTriggerController(
IRecipeManager recipeManager,
UserManager<User> userManager,
IMemoryCache memoryCache)
IMemoryCache memoryCache,
IExternalServiceManager externalServiceManager)
{
_recipeManager = recipeManager;
_userManager = userManager;
_externalServiceManager = externalServiceManager;
_memoryCache = memoryCache;
}
@ -57,7 +61,16 @@ namespace BtcTransmuter.Abstractions.Triggers
{
return View(modelResult.showViewModel);
}
if (!string.IsNullOrEmpty(modelResult.ToSave.ExternalServiceId))
{
var externalService= await _externalServiceManager.GetExternalServiceData(
modelResult.ToSave.ExternalServiceId,
GetUserId());
if (externalService == null)
{
return BadRequest("what you tryin to pull bro");
}
}
await _recipeManager.AddOrUpdateRecipeTrigger(modelResult.ToSave);
return RedirectToAction("EditRecipe", "Recipes", new
{

View File

@ -20,7 +20,7 @@ namespace BtcTransmuter.Abstractions.Triggers
public abstract string Name { get; }
public abstract string Description { get; }
public abstract string ViewPartial { get; }
protected abstract string ControllerName { get; }
public abstract string ControllerName { get; }
public Task<IActionResult> EditData(RecipeTrigger data)
{
@ -46,27 +46,32 @@ namespace BtcTransmuter.Abstractions.Triggers
TTriggerData triggerData, TTriggerParameters parameters);
public Task<bool> IsTriggered(ITrigger trigger, RecipeTrigger recipeTrigger)
public async Task<bool> IsTriggered(ITrigger trigger, RecipeTrigger recipeTrigger)
{
if (recipeTrigger.TriggerId != trigger.Id || trigger.Id != TriggerId)
{
return Task.FromResult(false);
return false;
}
var triggerData = trigger.Get<TTriggerData>();
var triggerData = await GetTriggerData(trigger);
if (typeof(TTriggerParameters).IsAssignableFrom(typeof(IUseExternalService)) &&
if (typeof(IUseExternalService).IsAssignableFrom(typeof(TTriggerData)) &&
((IUseExternalService) triggerData).ExternalServiceId != recipeTrigger.ExternalServiceId)
{
return Task.FromResult(false);
return false;
}
return IsTriggered(trigger, recipeTrigger, triggerData, recipeTrigger.Get<TTriggerParameters>());
return await IsTriggered(trigger, recipeTrigger, triggerData, recipeTrigger.Get<TTriggerParameters>());
}
public Task<object> GetData(ITrigger trigger)
public async Task<object> GetData(ITrigger trigger)
{
return Task.FromResult((object) trigger.Get<TTriggerData>());
return await GetTriggerData(trigger);
}
public virtual Task<TTriggerData> GetTriggerData(ITrigger trigger)
{
return Task.FromResult(trigger.Get<TTriggerData>());
}
public virtual Task AfterExecution(IEnumerable<Recipe> tupleItem1)

View File

@ -0,0 +1,23 @@
using System.Collections;
using System.ComponentModel.DataAnnotations;
namespace BtcTransmuter.Abstractions
{
public class EnsureMinimumElementsAttribute : ValidationAttribute
{
private readonly int _minElements;
public EnsureMinimumElementsAttribute(int minElements)
{
_minElements = minElements;
}
public override bool IsValid(object value)
{
if (value is IList list)
{
return list.Count >= _minElements;
}
return false;
}
}
}

View File

@ -1,19 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.2" />
<!--<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Design" Version="1.1.6" />-->
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.2" />
</ItemGroup>
<ItemGroup>
<Folder Include="Migrations" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection.Abstractions" Version="3.1.4" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.4" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.4" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,8 @@
using System;
namespace BtcTransmuter.Data.Encryption
{
[AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = false)]
sealed class EncryptedAttribute : Attribute
{ }
}

View File

@ -0,0 +1,22 @@
using System;
using System.Linq.Expressions;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace BtcTransmuter.Data.Encryption
{
class EncryptedConverter : ValueConverter<string, string>
{
private static IDataProtector _dataProtector;
private static string encryptedMarker = "ENCRYPTED:";
public EncryptedConverter(IDataProtector dataProtector, ConverterMappingHints mappingHints = default)
: base(EncryptExpr, DecryptExpr, mappingHints)
{
_dataProtector = dataProtector;
}
static Expression<Func<string, string>> DecryptExpr = x => x.StartsWith(encryptedMarker)? _dataProtector.Unprotect(x.Substring(encryptedMarker.Length)): x;
static Expression<Func<string, string>> EncryptExpr = x => $"{encryptedMarker}{_dataProtector.Protect(x)}";
}
}

View File

@ -0,0 +1,25 @@
using System.Linq;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.EntityFrameworkCore;
namespace BtcTransmuter.Data.Encryption
{
public static class ModelBuilderExtensions
{
public static void AddEncryptionValueConvertersToDecoratedEncryptedColumns(this ModelBuilder modelBuilder,
IDataProtector dataProtector)
{
foreach (var entityType in modelBuilder.Model.GetEntityTypes())
{
foreach (var property in entityType.GetProperties())
{
var attributes = property.PropertyInfo.GetCustomAttributes(typeof(EncryptedAttribute), false);
if (attributes.Any())
{
property.SetValueConverter(new EncryptedConverter(dataProtector));
}
}
}
}
}
}

View File

@ -1,11 +1,11 @@
using System.ComponentModel.DataAnnotations.Schema;
using BtcTransmuter.Data.Encryption;
using BtcTransmuter.Data.Models;
namespace BtcTransmuter.Data.Entities
{
public abstract class BaseEntity: IHasJsonData
public abstract class BaseEntity :BaseIdEntity, IHasJsonData
{
public string Id { get; set; }
public string DataJson { get; set; }
[Encrypted] public string DataJson { get; set; }
}
}

View File

@ -0,0 +1,10 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace BtcTransmuter.Data.Entities
{
public abstract class BaseIdEntity
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public string Id { get; set; }
}
}

View File

@ -2,9 +2,8 @@ using System.Collections.Generic;
namespace BtcTransmuter.Data.Entities
{
public class Recipe
public class Recipe : BaseIdEntity
{
public string Id { get; set; }
public string UserId { get; set; }
public string Name { get; set; }
public bool Enabled { get; set; }
@ -12,6 +11,14 @@ namespace BtcTransmuter.Data.Entities
public RecipeTrigger RecipeTrigger { get; set; }
public List<RecipeAction> RecipeActions { get; set; } // executes all actions
public List<RecipeActionGroup>
RecipeActionGroups
{
get;
set;
} // executes actions in groups. Action in a group are executed syncrhonously and depending if the previous action executes
public List<RecipeInvocation> RecipeInvocations { get; set; } // log
}
}

View File

@ -5,11 +5,19 @@ namespace BtcTransmuter.Data.Entities
public class RecipeAction : BaseEntity
{
public string RecipeId { get; set; }
public string RecipeActionGroupId { get; set; }
public string ExternalServiceId { get; set; }
public string ActionId { get; set; }
public Recipe Recipe { get; set; }
public ExternalServiceData ExternalService { get; set; }
public List<RecipeInvocation> RecipeInvocations { get; set; }
public RecipeActionGroup RecipeActionGroup { get; set; }
public int Order { get; set; } = 0;
public override string ToString()
{
return $"{ActionId} {(ExternalService == null ? string.Empty : $"using service {ExternalService.Name}")}";
}
}
}

View File

@ -0,0 +1,13 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
namespace BtcTransmuter.Data.Entities
{
public class RecipeActionGroup : BaseIdEntity
{
public string RecipeId { get; set; }
public Recipe Recipe { get; set; }
public List<RecipeAction> RecipeActions { get; set; }
}
}

View File

@ -1,17 +1,17 @@
using System;
using System.ComponentModel.DataAnnotations;
namespace BtcTransmuter.Data.Entities
{
public class RecipeInvocation
public class RecipeInvocation: BaseIdEntity
{
public string Id { get; set; }
public string RecipeId { get; set; }
public string RecipeActionId { get; set; }
public string RecipeAction { get; set; }
public string TriggerDataJson { get; set; }
public string ActionResult { get; set; }
public DateTime Timestamp { get; set; }
public Recipe Recipe { get; set; }
public RecipeAction RecipeAction { get; set; }
}
}

View File

@ -0,0 +1,7 @@
namespace BtcTransmuter.Data.Entities
{
public class Settings: BaseEntity
{
public string Key { get; set; }
}
}

View File

@ -1,10 +1,26 @@
using System.Collections.Generic;
using BtcTransmuter.Data.Encryption;
using BtcTransmuter.Data.Models;
using Microsoft.AspNetCore.Identity;
namespace BtcTransmuter.Data.Entities
{
public class User : IdentityUser
public class User : IdentityUser, IHasJsonData
{
public List<Recipe> Recipes { get; set; }
[Encrypted] public string DataJson { get; set; }
}
public class UserBlob
{
public bool BasicAuth { get; set; }
public BTCPayAuthDetails BTCPayAuthDetails { get; set; } = new BTCPayAuthDetails();
}
public class BTCPayAuthDetails
{
public string UserId { get; set; }
public string AccessToken { get; set; }
}
}

View File

@ -1,3 +1,4 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace BtcTransmuter.Data.Models
@ -6,12 +7,12 @@ namespace BtcTransmuter.Data.Models
{
public static T Get<T>(this IHasJsonData i)
{
return JObject.Parse(i.DataJson ?? "{}").ToObject<T>();
return JsonConvert.DeserializeObject<T>(i.DataJson ?? "{}");
}
public static void Set<T>(this IHasJsonData i, T data)
{
i.DataJson = JObject.FromObject(data).ToString();
i.DataJson = JsonConvert.SerializeObject(data);
}
}
}

View File

@ -0,0 +1,166 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using BtcTransmuter.Abstractions.ExternalServices;
using BtcTransmuter.Abstractions.Triggers;
using BtcTransmuter.Data.Entities;
using BtcTransmuter.Data.Models;
using BtcTransmuter.Extension.BtcPayServer.ExternalServices.BtcPayServer;
using BtcTransmuter.Extension.BtcPayServer.HostedServices;
using BtcTransmuter.Extension.BtcPayServer.Triggers.InvoiceStatusChanged;
using BtcTransmuter.Tests.Base;
using Moq;
using NBitcoin;
using NBitpayClient;
using Newtonsoft.Json;
using Xunit;
using Assert = Xunit.Assert;
namespace BtcTransmuter.Extension.BtcPayServer.Tests
{
public class BtcPayInvoiceWatcherHostedServiceTests : BaseTests
{
[Fact]
public async Task CanDetectInvoiceChanges()
{
var externalServiceManager = new Mock<IExternalServiceManager>();
var triggerDispatcher = new Mock<ITriggerDispatcher>();
var externalServices = new List<ExternalServiceData>()
{
new ExternalServiceData()
{
Type = BtcPayServerService.BtcPayServerServiceType,
Id = "A",
Name = "A",
DataJson = JsonConvert.SerializeObject(new BtcPayServerExternalServiceData())
}
};
var invoices = new List<BtcPayInvoice>()
{
new BtcPayInvoice()
{
Id = "A-A",
Status = Invoice.STATUS_NEW,
CurrentTime = DateTimeOffset.Now,
InvoiceTime = DateTimeOffset.Now,
ExpirationTime = DateTimeOffset.Now,
}
};
ITrigger dispatchedTrigger = null;
triggerDispatcher.Setup(dispatcher => dispatcher.DispatchTrigger(It.IsAny<ITrigger>()))
.Callback<ITrigger>((x) => { dispatchedTrigger = x; }).Returns(Task.CompletedTask);
var mockBitPay = new TestBitpay();
mockBitPay.Invoices = () => invoices.ToArray();
var btcpayserviceMock = new Mock<BtcPayServerService>();
btcpayserviceMock.Setup(serverService => serverService.ConstructClient())
.Returns(() => mockBitPay);
btcpayserviceMock.Setup(serverService => serverService.CheckAccess()).ReturnsAsync(() => true);
btcpayserviceMock.Setup(serverService => serverService.GetData()).Returns(() => externalServices[0].Get<BtcPayServerExternalServiceData>());
externalServiceManager
.Setup(manager => manager.GetExternalServicesData(It.IsAny<ExternalServicesDataQuery>()))
.ReturnsAsync(() => externalServices);
var flag = 0;
externalServiceManager
.Setup(manager => manager.UpdateInternalData(It.IsAny<string>(), It.IsAny<object>()))
.Callback<string, object>((key, data) =>
{
externalServices[0].Set(data);
flag++;
externalServiceManager.Raise(manager => manager.ExternalServiceDataUpdated+=null, new UpdatedItem<ExternalServiceData>()
{
Item = externalServices[0],
Action = UpdatedItem<ExternalServiceData>.UpdateAction.Updated
});
})
.Returns(Task.CompletedTask);
var service =
new TestBtcPayInvoiceWatcherHostedService(externalServiceManager.Object, triggerDispatcher.Object);
service.ConvertData = data => btcpayserviceMock.Object;
await service.StartAsync(CancellationToken.None);
while (flag == 0)
{
await Task.Delay(200);
}
externalServiceManager.Verify(
manager => manager.GetExternalServicesData(It.IsAny<ExternalServicesDataQuery>()), Times.Once);
triggerDispatcher.Verify(dispatcher => dispatcher.DispatchTrigger(It.IsAny<ITrigger>()), Times.Once);
var invoice = Assert.IsType<InvoiceStatusChangedTrigger>(dispatchedTrigger).Data.Invoice;
Assert.Equal(invoices[0].Id, invoice.Id);
Assert.Equal(invoices[0].Status, invoice.Status);
invoices[0].Status = Invoice.STATUS_PAID;
while (flag == 1)
{
await Task.Delay(200);
}
triggerDispatcher.Verify(dispatcher => dispatcher.DispatchTrigger(It.IsAny<ITrigger>()), Times.Exactly(2));
invoice = Assert.IsType<InvoiceStatusChangedTrigger>(dispatchedTrigger).Data.Invoice;
Assert.Equal(invoices[0].Id, invoice.Id);
Assert.Equal(invoices[0].Status, invoice.Status);
}
public class TestBtcPayInvoiceWatcherHostedService : BtcPayInvoiceWatcherHostedService
{
public TestBtcPayInvoiceWatcherHostedService(IExternalServiceManager externalServiceManager,
ITriggerDispatcher triggerDispatcher) : base(externalServiceManager, triggerDispatcher)
{
}
public Func<ExternalServiceData, BtcPayServerService> ConvertData = null;
protected override BtcPayServerService GetServiceFromData(ExternalServiceData externalServiceData)
{
return ConvertData == null
? base.GetServiceFromData(externalServiceData)
: ConvertData(externalServiceData);
}
protected override TimeSpan CheckInterval { get; } = TimeSpan.FromSeconds(2);
}
public class TestBitpay : Bitpay
{
public TestBitpay(Key ecKey, Uri envUrl) : base(ecKey, envUrl)
{
}
public TestBitpay(): base(new Key(), new Uri("https://gozo.com"))
{
}
public Func<Invoice[]> Invoices;
public override Task<T[]> GetInvoicesAsync<T>(DateTime? dateStart = null, DateTime? dateEnd = null)
{
if (Invoices != null)
{
return Task.FromResult(Invoices.Invoke().Select(invoice => (T) invoice).ToArray());
}
return base.GetInvoicesAsync<T>(dateStart, dateEnd);
}
}
}
}

View File

@ -0,0 +1,23 @@
using System;
using System.Linq;
using BtcTransmuter.Data.Entities;
using BtcTransmuter.Extension.BtcPayServer.ExternalServices.BtcPayServer;
using BtcTransmuter.Tests.Base;
using Xunit;
namespace BtcTransmuter.Extension.BtcPayServer.Tests
{
public class
BtcPayServerServiceTests : BaseExternalServiceTest<BtcPayServerService, BtcPayServerExternalServiceData>
{
protected override BtcPayServerService GetExternalService(params object[] setupArgs)
{
if (setupArgs?.Any() ?? false)
{
return new BtcPayServerService((ExternalServiceData) setupArgs.First());
}
return new BtcPayServerService();
}
}
}

View File

@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="Moq" Version="4.14.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BtcTransmuter.Extension.BtcPayServer\BtcTransmuter.Extension.BtcPayServer.csproj" />
<ProjectReference Include="..\BtcTransmuter.Tests.Base\BtcTransmuter.Tests.Base.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,15 @@
using System.Threading.Tasks;
using BtcTransmuter.Extension.BtcPayServer.Actions.GetInvoice;
using BtcTransmuter.Extension.BtcPayServer.HostedServices;
using BtcTransmuter.Tests.Base;
using Xunit;
namespace BtcTransmuter.Extension.BtcPayServer.Tests
{
public class
GetInvoiceDataActionHandlerTests : BaseActionTest<GetInvoiceDataActionHandler, GetInvoiceData, BtcPayInvoice>
{
}
}

View File

@ -0,0 +1,12 @@
using System.Collections.Generic;
using BtcTransmuter.Extension.BtcPayServer.Actions.GetPaymentsFromInvoice;
using BtcTransmuter.Tests.Base;
using NBitpayClient;
namespace BtcTransmuter.Extension.BtcPayServer.Tests
{
public class
GetPaymentsFromInvoiceDataActionHandlerTests : BaseActionTest<GetPaymentsFromInvoiceDataActionHandler, GetPaymentsFromInvoiceData, List<InvoicePaymentInfo>>
{
}
}

View File

@ -0,0 +1,306 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BtcTransmuter.Data.Entities;
using BtcTransmuter.Extension.BtcPayServer.HostedServices;
using BtcTransmuter.Extension.BtcPayServer.Triggers.InvoiceStatusChanged;
using BtcTransmuter.Tests.Base;
using NBitpayClient;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Xunit;
using Assert = Xunit.Assert;
namespace BtcTransmuter.Extension.BtcPayServer.Tests
{
public class
InvoiceStatusChangedTriggerHandlerTests : BaseTriggerTest<InvoiceStatusChangedTriggerHandler,
InvoiceStatusChangedTriggerData,
InvoiceStatusChangedTriggerParameters>
{
[Fact]
public async Task IsTriggered_ExecutesCorrectly()
{
var handler = GetTriggerHandlerInstance();
//any status combination
var parameters = new InvoiceStatusChangedTriggerParameters()
{
Conditions = InvoiceStatusChangedController.AllowedStatuses.Select(item => new InvoiceStatusChangeCondition()
{
Status = item.Value,
ExceptionStatuses = InvoiceStatusChangedController.AllowedExceptionStatus.Select(item2 => item2.Value).ToList()
}).ToList()
};
Assert.True(await handler.IsTriggered(new InvoiceStatusChangedTrigger()
{
Data = new InvoiceStatusChangedTriggerData()
{
ExternalServiceId = "A",
Invoice = new BtcPayInvoice()
{
Status = BtcPayInvoice.STATUS_NEW,
CurrentTime = DateTimeOffset.Now,
InvoiceTime = DateTimeOffset.Now,
ExpirationTime = DateTimeOffset.Now
}
}
},
new RecipeTrigger()
{
TriggerId = handler.TriggerId,
ExternalServiceId = "A",
DataJson = JsonConvert.SerializeObject(parameters)
}));
//the external service id is not the same, if it triggers you are in deep shit
Assert.False(await handler.IsTriggered(new InvoiceStatusChangedTrigger()
{
Data = new InvoiceStatusChangedTriggerData()
{
ExternalServiceId = "B",
Invoice = new BtcPayInvoice()
{
Status = BtcPayInvoice.STATUS_NEW,
CurrentTime = DateTimeOffset.Now,
InvoiceTime = DateTimeOffset.Now,
ExpirationTime = DateTimeOffset.Now
}
}
},
new RecipeTrigger()
{
TriggerId = handler.TriggerId,
ExternalServiceId = "A",
DataJson = JsonConvert.SerializeObject(parameters)
}));
Assert.True(await handler.IsTriggered(new InvoiceStatusChangedTrigger()
{
Data = new InvoiceStatusChangedTriggerData()
{
ExternalServiceId = "A",
Invoice = new BtcPayInvoice()
{
Status = BtcPayInvoice.STATUS_PAID,
CurrentTime = DateTimeOffset.Now,
InvoiceTime = DateTimeOffset.Now,
ExpirationTime = DateTimeOffset.Now
}
}
},
new RecipeTrigger()
{
TriggerId = handler.TriggerId,
ExternalServiceId = "A",
DataJson = JsonConvert.SerializeObject(parameters)
}));
Assert.True(await handler.IsTriggered(new InvoiceStatusChangedTrigger()
{
Data = new InvoiceStatusChangedTriggerData()
{
ExternalServiceId = "A",
Invoice = new BtcPayInvoice()
{
Status = BtcPayInvoice.STATUS_INVALID,
ExceptionStatus = new JValue(Invoice.EXSTATUS_PAID_PARTIAL),
CurrentTime = DateTimeOffset.Now,
InvoiceTime = DateTimeOffset.Now,
ExpirationTime = DateTimeOffset.Now
}
}
},
new RecipeTrigger()
{
TriggerId = handler.TriggerId,
ExternalServiceId = "A",
DataJson = JsonConvert.SerializeObject(parameters)
}));
//only paid status with no exception statuses
parameters.Conditions = new List<InvoiceStatusChangeCondition>()
{
new InvoiceStatusChangeCondition()
{
Status = Invoice.STATUS_PAID,
ExceptionStatuses = new List<string>()
{
Invoice.EXSTATUS_FALSE
}
}
};
Assert.True(await handler.IsTriggered(new InvoiceStatusChangedTrigger()
{
Data = new InvoiceStatusChangedTriggerData()
{
ExternalServiceId = "A",
Invoice = new BtcPayInvoice()
{
Status = BtcPayInvoice.STATUS_PAID,
CurrentTime = DateTimeOffset.Now,
InvoiceTime = DateTimeOffset.Now,
ExpirationTime = DateTimeOffset.Now
}
}
},
new RecipeTrigger()
{
TriggerId = handler.TriggerId,
ExternalServiceId = "A",
DataJson = JsonConvert.SerializeObject(parameters)
}));
Assert.False(await handler.IsTriggered(new InvoiceStatusChangedTrigger()
{
Data = new InvoiceStatusChangedTriggerData()
{
ExternalServiceId = "A",
Invoice = new BtcPayInvoice()
{
Status = BtcPayInvoice.STATUS_PAID,
ExceptionStatus = Invoice.EXSTATUS_PAID_PARTIAL,
CurrentTime = DateTimeOffset.Now,
InvoiceTime = DateTimeOffset.Now,
ExpirationTime = DateTimeOffset.Now
}
}
},
new RecipeTrigger()
{
TriggerId = handler.TriggerId,
ExternalServiceId = "A",
DataJson = JsonConvert.SerializeObject(parameters)
}));
Assert.False(await handler.IsTriggered(new InvoiceStatusChangedTrigger()
{
Data = new InvoiceStatusChangedTriggerData()
{
ExternalServiceId = "A",
Invoice = new BtcPayInvoice()
{
Status = BtcPayInvoice.STATUS_NEW,
CurrentTime = DateTimeOffset.Now,
InvoiceTime = DateTimeOffset.Now,
ExpirationTime = DateTimeOffset.Now
}
}
},
new RecipeTrigger()
{
TriggerId = handler.TriggerId,
ExternalServiceId = "A",
DataJson = JsonConvert.SerializeObject(parameters)
}));
parameters.Conditions = new List<InvoiceStatusChangeCondition>()
{
new InvoiceStatusChangeCondition()
{
Status = Invoice.STATUS_PAID,
ExceptionStatuses = new List<string>()
{
Invoice.EXSTATUS_FALSE
}
},
new InvoiceStatusChangeCondition()
{
Status = Invoice.STATUS_INVALID,
ExceptionStatuses = new List<string>()
{
"paidLate"
}
}
};
Assert.False(await handler.IsTriggered(new InvoiceStatusChangedTrigger()
{
Data = new InvoiceStatusChangedTriggerData()
{
ExternalServiceId = "A",
Invoice = new BtcPayInvoice()
{
Status = BtcPayInvoice.STATUS_INVALID,
CurrentTime = DateTimeOffset.Now,
InvoiceTime = DateTimeOffset.Now,
ExpirationTime = DateTimeOffset.Now
}
}
},
new RecipeTrigger()
{
TriggerId = handler.TriggerId,
ExternalServiceId = "A",
DataJson = JsonConvert.SerializeObject(parameters)
}));
Assert.False(await handler.IsTriggered(new InvoiceStatusChangedTrigger()
{
Data = new InvoiceStatusChangedTriggerData()
{
ExternalServiceId = "A",
Invoice = new BtcPayInvoice()
{
Status = BtcPayInvoice.STATUS_PAID,
ExceptionStatus = Invoice.EXSTATUS_PAID_OVER,
CurrentTime = DateTimeOffset.Now,
InvoiceTime = DateTimeOffset.Now,
ExpirationTime = DateTimeOffset.Now
}
}
},
new RecipeTrigger()
{
TriggerId = handler.TriggerId,
ExternalServiceId = "A",
DataJson = JsonConvert.SerializeObject(parameters)
}));
Assert.True(await handler.IsTriggered(new InvoiceStatusChangedTrigger()
{
Data = new InvoiceStatusChangedTriggerData()
{
ExternalServiceId = "A",
Invoice = new BtcPayInvoice()
{
Status = BtcPayInvoice.STATUS_PAID,
ExceptionStatus = Invoice.EXSTATUS_FALSE,
CurrentTime = DateTimeOffset.Now,
InvoiceTime = DateTimeOffset.Now,
ExpirationTime = DateTimeOffset.Now
}
}
},
new RecipeTrigger()
{
TriggerId = handler.TriggerId,
ExternalServiceId = "A",
DataJson = JsonConvert.SerializeObject(parameters)
}));
Assert.True(await handler.IsTriggered(new InvoiceStatusChangedTrigger()
{
Data = new InvoiceStatusChangedTriggerData()
{
ExternalServiceId = "A",
Invoice = new BtcPayInvoice()
{
Status = BtcPayInvoice.STATUS_INVALID,
ExceptionStatus = "paidLate",
CurrentTime = DateTimeOffset.Now,
InvoiceTime = DateTimeOffset.Now,
ExpirationTime = DateTimeOffset.Now
}
}
},
new RecipeTrigger()
{
TriggerId = handler.TriggerId,
ExternalServiceId = "A",
DataJson = JsonConvert.SerializeObject(parameters)
}));
}
}
}

View File

@ -0,0 +1,9 @@
using BtcTransmuter.Abstractions.Actions;
namespace BtcTransmuter.Extension.BtcPayServer.Actions
{
public class BtcPayServerActionHandlerResult<T> : TypedActionHandlerResult<T>
{
public override string DataJson => NBitcoin.JsonConverters.Serializer.ToString(Data);
}
}

View File

@ -0,0 +1,85 @@
using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
using BtcTransmuter.Abstractions.Actions;
using BtcTransmuter.Abstractions.ExternalServices;
using BtcTransmuter.Abstractions.Recipes;
using BtcTransmuter.Data.Entities;
using BtcTransmuter.Data.Models;
using BtcTransmuter.Extension.BtcPayServer.ExternalServices.BtcPayServer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.Extensions.Caching.Memory;
namespace BtcTransmuter.Extension.BtcPayServer.Actions.GetInvoice
{
[Route("btcpayserver-plugin/actions/[controller]")]
[Authorize]
public class GetInvoiceController : BaseActionController<
GetInvoiceController.GetInvoiceViewModel,
GetInvoiceData>
{
private readonly IExternalServiceManager _externalServiceManager;
public GetInvoiceController(IMemoryCache memoryCache,
UserManager<User> userManager,
IRecipeManager recipeManager,
IExternalServiceManager externalServiceManager) : base(
memoryCache,
userManager, recipeManager, externalServiceManager)
{
_externalServiceManager = externalServiceManager;
}
protected override async Task<GetInvoiceViewModel> BuildViewModel(RecipeAction from)
{
var services = await _externalServiceManager.GetExternalServicesData(new ExternalServicesDataQuery
{
Type = new[] {BtcPayServerService.BtcPayServerServiceType},
UserId = GetUserId()
});
var fromData = from.Get<GetInvoiceData>();
return new GetInvoiceViewModel
{
RecipeId = from.RecipeId,
ExternalServiceId = from.ExternalServiceId,
ExternalServices = new SelectList(services, nameof(ExternalServiceData.Id),
nameof(ExternalServiceData.Name), from.ExternalServiceId),
InvoiceId = fromData.InvoiceId,
};
}
protected override async Task<(RecipeAction ToSave, GetInvoiceViewModel showViewModel)> BuildModel(
GetInvoiceViewModel viewModel, RecipeAction mainModel)
{
if (ModelState.IsValid)
{
mainModel.ExternalServiceId = viewModel.ExternalServiceId;
mainModel.Set<GetInvoiceData>(viewModel);
return (mainModel, null);
}
var services = await _externalServiceManager.GetExternalServicesData(new ExternalServicesDataQuery
{
Type = new[] {BtcPayServerService.BtcPayServerServiceType},
UserId = GetUserId()
});
viewModel.ExternalServices = new SelectList(services, nameof(ExternalServiceData.Id),
nameof(ExternalServiceData.Name), viewModel.ExternalServiceId);
return (null, viewModel);
}
public class GetInvoiceViewModel : GetInvoiceData, IActionViewModel, IUseExternalService
{
public string RecipeId { get; set; }
public string RecipeActionIdInGroupBeforeThisOne { get; set; }
public SelectList ExternalServices { get; set; }
public SelectList PaymentTypes { get; set; }
[Display(Name = "BtcPay External Service")]
[Required]
public string ExternalServiceId { get; set; }
}
}
}

View File

@ -0,0 +1,10 @@
using System.ComponentModel.DataAnnotations;
namespace BtcTransmuter.Extension.BtcPayServer.Actions.GetInvoice
{
public class GetInvoiceData
{
[Required]
public string InvoiceId { get; set; }
}
}

View File

@ -0,0 +1,46 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BtcTransmuter.Abstractions.Actions;
using BtcTransmuter.Data.Entities;
using BtcTransmuter.Extension.BtcPayServer.ExternalServices.BtcPayServer;
using BtcTransmuter.Extension.BtcPayServer.HostedServices;
using BtcTransmuter.Extension.DynamicServices;
using NBitpayClient;
namespace BtcTransmuter.Extension.BtcPayServer.Actions.GetInvoice
{
public class GetInvoiceDataActionHandler : BaseActionHandler<GetInvoiceData, BtcPayInvoice>
{
public override string ActionId => "GetInvoice";
public override string Name => "Get BTCPay invoice";
public override string Description =>
"Get a specific btcpay invoice";
public override string ViewPartial => "ViewGetInvoiceAction";
public override string ControllerName => "GetInvoice";
public GetInvoiceDataActionHandler()
{
}
protected override async Task<TypedActionHandlerResult<BtcPayInvoice>> Execute(Dictionary<string, object> data, RecipeAction recipeAction,
GetInvoiceData actionData)
{
var externalService = await recipeAction.GetExternalService();
var service = new BtcPayServerService(externalService);
var invoiceId = InterpolateString(actionData.InvoiceId, data);
var client = service.ConstructClient();
var invoice = await client.GetInvoiceAsync<BtcPayInvoice>(invoiceId);
return new BtcPayServerActionHandlerResult<BtcPayInvoice>()
{
Executed = true,
TypedData = invoice,
Result = $"fetched invoice {invoiceId}"
};
}
}
}

View File

@ -0,0 +1,98 @@
using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
using BtcTransmuter.Abstractions.Actions;
using BtcTransmuter.Abstractions.ExternalServices;
using BtcTransmuter.Abstractions.Recipes;
using BtcTransmuter.Data.Entities;
using BtcTransmuter.Data.Models;
using BtcTransmuter.Extension.BtcPayServer.ExternalServices.BtcPayServer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.Extensions.Caching.Memory;
namespace BtcTransmuter.Extension.BtcPayServer.Actions.GetPaymentsFromInvoice
{
[Route("btcpayserver-plugin/actions/[controller]")]
[Authorize]
public class GetPaymentsFromInvoiceController : BaseActionController<
GetPaymentsFromInvoiceController.GetPaymentsFromInvoiceViewModel,
GetPaymentsFromInvoiceData>
{
private readonly IExternalServiceManager _externalServiceManager;
public static readonly SelectListItem[] PaymentTypes =
{
new SelectListItem("Any", ""),
new SelectListItem("On-Chain", "BTCLike"),
new SelectListItem("Off-Chain", "LightningLike")
};
public GetPaymentsFromInvoiceController(IMemoryCache memoryCache,
UserManager<User> userManager,
IRecipeManager recipeManager,
IExternalServiceManager externalServiceManager) : base(
memoryCache,
userManager, recipeManager, externalServiceManager)
{
_externalServiceManager = externalServiceManager;
}
protected override async Task<GetPaymentsFromInvoiceViewModel> BuildViewModel(RecipeAction from)
{
var services = await _externalServiceManager.GetExternalServicesData(new ExternalServicesDataQuery
{
Type = new[] {BtcPayServerService.BtcPayServerServiceType},
UserId = GetUserId()
});
var fromData = from.Get<GetPaymentsFromInvoiceData>();
return new GetPaymentsFromInvoiceViewModel
{
RecipeId = from.RecipeId,
ExternalServiceId = from.ExternalServiceId,
ExternalServices = new SelectList(services, nameof(ExternalServiceData.Id),
nameof(ExternalServiceData.Name), from.ExternalServiceId),
PaymentTypes = new SelectList(PaymentTypes, nameof(SelectListItem.Value), nameof(SelectListItem.Text),
fromData.PaymentType),
PaymentType = fromData.PaymentType,
InvoiceId = fromData.InvoiceId,
CryptoCode = fromData.CryptoCode
};
}
protected override async Task<(RecipeAction ToSave, GetPaymentsFromInvoiceViewModel showViewModel)> BuildModel(
GetPaymentsFromInvoiceViewModel viewModel, RecipeAction mainModel)
{
if (ModelState.IsValid)
{
mainModel.ExternalServiceId = viewModel.ExternalServiceId;
mainModel.Set<GetPaymentsFromInvoiceData>(viewModel);
return (mainModel, null);
}
var services = await _externalServiceManager.GetExternalServicesData(new ExternalServicesDataQuery
{
Type = new[] {BtcPayServerService.BtcPayServerServiceType},
UserId = GetUserId()
});
viewModel.ExternalServices = new SelectList(services, nameof(ExternalServiceData.Id),
nameof(ExternalServiceData.Name), viewModel.ExternalServiceId);
viewModel.PaymentTypes = new SelectList(PaymentTypes, nameof(SelectListItem.Value),
nameof(SelectListItem.Text), viewModel.PaymentType);
return (null, viewModel);
}
public class GetPaymentsFromInvoiceViewModel : GetPaymentsFromInvoiceData, IActionViewModel, IUseExternalService
{
public string RecipeId { get; set; }
public string RecipeActionIdInGroupBeforeThisOne { get; set; }
public SelectList ExternalServices { get; set; }
public SelectList PaymentTypes { get; set; }
[Display(Name = "BtcPay External Service")]
[Required]
public string ExternalServiceId { get; set; }
}
}
}

View File

@ -0,0 +1,13 @@
using System.ComponentModel.DataAnnotations;
namespace BtcTransmuter.Extension.BtcPayServer.Actions.GetPaymentsFromInvoice
{
public class GetPaymentsFromInvoiceData
{
[Required]
public string InvoiceId { get; set; }
[Required]
public string CryptoCode { get; set; }
public string PaymentType { get; set; }
}
}

View File

@ -0,0 +1,53 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BtcTransmuter.Abstractions.Actions;
using BtcTransmuter.Data.Entities;
using BtcTransmuter.Extension.BtcPayServer.ExternalServices.BtcPayServer;
using BtcTransmuter.Extension.BtcPayServer.HostedServices;
using BtcTransmuter.Extension.DynamicServices;
using NBitpayClient;
namespace BtcTransmuter.Extension.BtcPayServer.Actions.GetPaymentsFromInvoice
{
public class GetPaymentsFromInvoiceDataActionHandler : BaseActionHandler<GetPaymentsFromInvoiceData, List<InvoicePaymentInfo>>
{
public override string ActionId => "GetPaymentsFromInvoice";
public override string Name => "Get payments on BTCPay invoice";
public override string Description =>
"Get the payments made to a specific btcpay invoice";
public override string ViewPartial => "ViewGetPaymentsFromInvoiceAction";
public override string ControllerName => "GetPaymentsFromInvoice";
public GetPaymentsFromInvoiceDataActionHandler()
{
}
protected override async Task<TypedActionHandlerResult<List<InvoicePaymentInfo>>> Execute(Dictionary<string, object> data, RecipeAction recipeAction,
GetPaymentsFromInvoiceData actionData)
{
var externalService = await recipeAction.GetExternalService();
var service = new BtcPayServerService(externalService);
var invoiceId = InterpolateString(actionData.InvoiceId, data);
var client = service.ConstructClient();
var invoice = await client.GetInvoiceAsync<BtcPayInvoice>(invoiceId);
var payments = invoice.CryptoInfo.Where(info => info.CryptoCode.Equals(actionData.CryptoCode))
.SelectMany(info => info.Payments)
.Where(x =>
string.IsNullOrEmpty(actionData.PaymentType) ||
x.PaymentType.Equals(actionData.PaymentType))
.ToList();
return new BtcPayServerActionHandlerResult<List<InvoicePaymentInfo>>()
{
Executed = true,
TypedData = payments,
Result = $"found {payments.Count} {actionData.CryptoCode} payments in invoice {invoiceId}"
};
}
}
}

View File

@ -1,11 +1,10 @@
using BtcTransmuter.Abstractions.Extensions;
namespace BtcTransmuter.Extension.BtcPayServer
{
public class BtcPayServerBtcTransmuterExtension : BtcTransmuterExtension
{
public override string Name => "BtcPayServer Plugin";
public override string Version => "0.0.1";
protected override int Priority => 0;
}
}

View File

@ -1,26 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\BtcTransmuter.Abstractions\BtcTransmuter.Abstractions.csproj" />
<ProjectReference Include="..\BtcTransmuter.Abstractions\BtcTransmuter.Abstractions.csproj" />
<ProjectReference Include="..\BtcTransmuter.Extension.DynamicServices\BtcTransmuter.Extension.DynamicServices.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="2.2.0" />
<PackageReference Include="NBitcoin" Version="4.1.1.82" />
<PackageReference Include="NBitpayClient" Version="1.0.0.32" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.4" />
<PackageReference Include="NBitcoin" Version="5.0.40" />
<PackageReference Include="NBitpayClient" Version="1.0.0.38" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\BtcPayServer\EditData.cshtml" />
<Content Include="Views\InvoiceStatusChanged\EditData.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Styles\**;Views\**;Scripts\**" />
</ItemGroup>
</Project>

View File

@ -31,7 +31,7 @@ namespace BtcTransmuter.Extension.BtcPayServer.ExternalServices.BtcPayServer
{
Seed = clientData.Seed ?? new Mnemonic(Wordlist.English, WordCount.Twelve).ToString(),
Server = clientData.Server,
PairingUrl = await client.GetPairingUrl(),
PairingUrl = await client.GetPairingUrl(data.Name),
Paired = await client.CheckAccess()
};
}
@ -69,7 +69,7 @@ namespace BtcTransmuter.Extension.BtcPayServer.ExternalServices.BtcPayServer
{
Seed = serviceData.Seed ?? new Mnemonic(Wordlist.English, WordCount.Twelve).ToString(),
Server = serviceData.Server,
PairingUrl = await service.GetPairingUrl(),
PairingUrl = await service.GetPairingUrl(mainModel.Name),
Paired = await service.CheckAccess()
});
}
@ -79,7 +79,7 @@ namespace BtcTransmuter.Extension.BtcPayServer.ExternalServices.BtcPayServer
{
viewModel.Seed = viewModel.Seed ?? new Mnemonic(Wordlist.English, WordCount.Twelve).ToString();
service.SetData(viewModel);
viewModel.PairingUrl = await service.GetPairingUrl();
viewModel.PairingUrl = await service.GetPairingUrl(mainModel.Name);
viewModel.Paired = false;
if (!string.IsNullOrEmpty(viewModel.PairingCode))
{

View File

@ -6,7 +6,8 @@ namespace BtcTransmuter.Extension.BtcPayServer.ExternalServices.BtcPayServer
{
public class BtcPayServerExternalServiceData
{
[Required] public Uri Server { get; set; }
[Required][Display(Name = "BtcPay Host Url")]
[Validation.Uri] public Uri Server { get; set; }
public string Seed { get; set; }

View File

@ -19,7 +19,7 @@ namespace BtcTransmuter.Extension.BtcPayServer.ExternalServices.BtcPayServer
public override string Name => "BtcPayServer External Service";
public override string Description => "BtcPayServer External Service to be able to interact with its services";
public override string ViewPartial => "ViewBtcPayServerExternalService";
protected override string ControllerName => "BtcPayServer";
public override string ControllerName => "BtcPayServer";
public BtcPayServerService() : base()
@ -30,7 +30,7 @@ namespace BtcTransmuter.Extension.BtcPayServer.ExternalServices.BtcPayServer
{
}
public Bitpay ConstructClient()
public virtual Bitpay ConstructClient()
{
try
{
@ -45,13 +45,20 @@ namespace BtcTransmuter.Extension.BtcPayServer.ExternalServices.BtcPayServer
}
}
public async Task<bool> CheckAccess()
public virtual async Task<bool> CheckAccess()
{
var client = ConstructClient();
return client != null && await client.TestAccessAsync(Facade.Merchant);
try
{
var client = ConstructClient();
return client != null && await client.TestAccessAsync(Facade.Merchant);
}
catch (Exception)
{
return false;
}
}
public async Task<string> GetPairingUrl()
public async Task<string> GetPairingUrl(string label)
{
try
{
@ -62,14 +69,14 @@ namespace BtcTransmuter.Extension.BtcPayServer.ExternalServices.BtcPayServer
return null;
}
return (await client.RequestClientAuthorizationAsync("BtcTransmuter", Facade.Merchant))
return (await client.RequestClientAuthorizationAsync(label, Facade.Merchant))
.CreateLink(client.BaseUrl)
.ToString();
}
catch (Exception)
{
var data = GetData();
return new Uri(data.Server, "api-tokens").ToString();
return Uri.TryCreate(data.Server, "api-tokens", out var result) ? result.ToString() : null;
}
}
}

View File

@ -1,11 +1,17 @@
using System.ComponentModel.DataAnnotations;
namespace BtcTransmuter.Extension.BtcPayServer.ExternalServices.BtcPayServer
{
public class EditBtcPayServerDataViewModel : BtcPayServerExternalServiceData
{
public string Action { get; set; }
public string PairingUrl { get; set; }
[Display(Name =
"Pairing code from server initiated pairing. Alternatively, leave blank and click next to generate a pairing request url")]
public string PairingCode { get; set; }
public bool Paired { get; set; }
}
}

View File

@ -68,5 +68,7 @@ namespace BtcTransmuter.Extension.BtcPayServer.HostedServices
{
return true;
}
}
}

View File

@ -19,6 +19,7 @@ namespace BtcTransmuter.Extension.BtcPayServer.HostedServices
private readonly IExternalServiceManager _externalServiceManager;
private readonly ITriggerDispatcher _triggerDispatcher;
private ConcurrentDictionary<string, BtcPayServerService> _externalServices;
protected virtual TimeSpan CheckInterval { get; } = TimeSpan.FromMinutes(1);
public BtcPayInvoiceWatcherHostedService(IExternalServiceManager externalServiceManager,
ITriggerDispatcher triggerDispatcher)
@ -39,19 +40,24 @@ namespace BtcTransmuter.Extension.BtcPayServer.HostedServices
_externalServices = new ConcurrentDictionary<string, BtcPayServerService>(
externalServices
.Select(service =>
new KeyValuePair<string, BtcPayServerService>(service.Id, new BtcPayServerService(service))));
new KeyValuePair<string, BtcPayServerService>(service.Id, GetServiceFromData(service))));
_externalServiceManager.ExternalServiceDataUpdated += ExternalServiceManagerOnExternalServiceUpdated;
_ = Loop(cancellationToken);
}
protected virtual BtcPayServerService GetServiceFromData(ExternalServiceData externalServiceData)
{
return new BtcPayServerService(externalServiceData);
}
private async Task Loop(CancellationToken cancellationToken)
{
while (!cancellationToken.IsCancellationRequested)
{
var tasks = _externalServices.Select(CheckInvoiceChangeInService);
await Task.WhenAll(tasks);
await Task.Delay(TimeSpan.FromMinutes(1), cancellationToken);
await Task.Delay(CheckInterval, cancellationToken);
}
}
@ -59,33 +65,46 @@ namespace BtcTransmuter.Extension.BtcPayServer.HostedServices
{
try
{
var (key, service) = pair;
if (!await service.CheckAccess())
{
return;
}
var data = service.GetData();
data.LastCheck = DateTime.Now;
if (data.MonitoredInvoiceStatuses == null)
{
data.MonitoredInvoiceStatuses = new Dictionary<string, string>();
}
var client = service.ConstructClient();
var invoices = await client.GetInvoicesAsync<BtcPayInvoice>(data.PairedDate);
foreach (var invoice in invoices)
{
//do not trigger on first run
if (data.LastCheck.HasValue)
var key = pair.Key;
var service = pair.Value;
if (!await service.CheckAccess())
{
if (data.MonitoredInvoiceStatuses.ContainsKey(invoice.Id))
return;
}
var data = service.GetData();
data.LastCheck = DateTime.Now;
if (data.MonitoredInvoiceStatuses == null)
{
data.MonitoredInvoiceStatuses = new Dictionary<string, string>();
}
var client = service.ConstructClient();
var invoices = await client.GetInvoicesAsync<BtcPayInvoice>(data.PairedDate, null);
foreach (var invoice in invoices)
{
//do not trigger on first run
if (data.LastCheck.HasValue)
{
if (data.MonitoredInvoiceStatuses[invoice.Id] != invoice.Status)
if (data.MonitoredInvoiceStatuses.ContainsKey(invoice.Id))
{
await _triggerDispatcher.DispatchTrigger(new InvoiceStatusChangedTrigger()
if (data.MonitoredInvoiceStatuses[invoice.Id] != invoice.Status)
{
_ = _triggerDispatcher.DispatchTrigger(new InvoiceStatusChangedTrigger()
{
Data = new InvoiceStatusChangedTriggerData()
{
Invoice = invoice,
ExternalServiceId = key
}
});
}
}
else
{
_ = _triggerDispatcher.DispatchTrigger(new InvoiceStatusChangedTrigger()
{
Data = new InvoiceStatusChangedTriggerData()
{
@ -95,26 +114,13 @@ namespace BtcTransmuter.Extension.BtcPayServer.HostedServices
});
}
}
else
{
await _triggerDispatcher.DispatchTrigger(new InvoiceStatusChangedTrigger()
{
Data = new InvoiceStatusChangedTriggerData()
{
Invoice = invoice,
ExternalServiceId = key
}
});
}
data.MonitoredInvoiceStatuses.AddOrReplace(invoice.Id, invoice.Status);
}
data.MonitoredInvoiceStatuses.AddOrReplace(invoice.Id, invoice.Status);
}
service.SetData(data);
service.SetData( data);
await _externalServiceManager.UpdateInternalData(key, data);
await _externalServiceManager.UpdateInternalData(key, data);
}
catch (Exception e)
{
@ -137,13 +143,13 @@ namespace BtcTransmuter.Extension.BtcPayServer.HostedServices
switch (e.Action)
{
case UpdatedItem<ExternalServiceData>.UpdateAction.Added:
_externalServices.TryAdd(e.Item.Id, new BtcPayServerService(e.Item));
_externalServices.TryAdd(e.Item.Id, GetServiceFromData(e.Item));
break;
case UpdatedItem<ExternalServiceData>.UpdateAction.Removed:
_externalServices.TryRemove(e.Item.Id, out var _);
break;
case UpdatedItem<ExternalServiceData>.UpdateAction.Updated:
_externalServices.TryUpdate(e.Item.Id, new BtcPayServerService(e.Item), null);
_externalServices.TryUpdate(e.Item.Id, GetServiceFromData(e.Item), null);
break;
default:
throw new ArgumentOutOfRangeException();

View File

@ -1,5 +1,9 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
using BtcTransmuter.Abstractions.Extensions;
using BtcTransmuter.Abstractions.ExternalServices;
using BtcTransmuter.Abstractions.Recipes;
using BtcTransmuter.Abstractions.Triggers;
@ -16,26 +20,42 @@ using NBitpayClient;
namespace BtcTransmuter.Extension.BtcPayServer.Triggers.InvoiceStatusChanged
{
[Authorize]
[Route("btcpayserver-plugin/triggers/invoice-status-changed")]
[Route("btcpayserver-plugin/triggers/[controller]")]
public class InvoiceStatusChangedController : BaseTriggerController<
InvoiceStatusChangedController.InvoiceStatusChangedTriggerViewModel, InvoiceStatusChangedTriggerParameters>
{
private readonly IExternalServiceManager _externalServiceManager;
private readonly SelectListItem[] AllowedStatuses = new SelectListItem[]
public static readonly SelectListItem[] AllowedStatuses = new SelectListItem[]
{
new SelectListItem() {Text = "Any Status", Value = null},
new SelectListItem() {Text = "New", Value = Invoice.STATUS_NEW},
new SelectListItem() {Text = "Paid", Value = Invoice.STATUS_PAID},
new SelectListItem() {Text = "Invalid", Value = Invoice.STATUS_INVALID},
new SelectListItem() {Text = "Confirmed", Value = Invoice.STATUS_CONFIRMED},
new SelectListItem() {Text = "Complete", Value = Invoice.STATUS_COMPLETE}
new SelectListItem() {Text = "Complete", Value = Invoice.STATUS_COMPLETE},
new SelectListItem() {Text = "Expired", Value = "expired"},
};
public static SelectListItem[] AllowedExceptionStatus = new SelectListItem[]
{
new SelectListItem() {Text = "None", Value = Invoice.EXSTATUS_FALSE},
new SelectListItem() {Text = "Paid partially", Value = Invoice.EXSTATUS_PAID_PARTIAL},
new SelectListItem() {Text = "Paid over", Value = Invoice.EXSTATUS_PAID_OVER},
new SelectListItem() {Text = "Paid late", Value = "paidLate"},
new SelectListItem() {Text = "Marked", Value = "marked"},
};
public InvoiceStatusChangedController(IRecipeManager recipeManager, UserManager<User> userManager,
public static SelectListItem[] GetAvailableStatuses(string[] usedKeys)
{
return AllowedStatuses.Where(item => !usedKeys.Contains(item.Value)).ToArray();
}
public InvoiceStatusChangedController(IRecipeManager recipeManager, UserManager<User> userManager,
IMemoryCache memoryCache, IExternalServiceManager externalServiceManager) : base(recipeManager, userManager,
memoryCache)
memoryCache, externalServiceManager)
{
_externalServiceManager = externalServiceManager;
}
@ -56,8 +76,7 @@ namespace BtcTransmuter.Extension.BtcPayServer.Triggers.InvoiceStatusChanged
nameof(ExternalServiceData.Name), data.ExternalServiceId),
RecipeId = data.RecipeId,
ExternalServiceId = data.ExternalServiceId,
Status = fromData.Status,
Statuses = new SelectList(AllowedStatuses, "Value", "Text", fromData.Status),
Conditions = fromData.Conditions,
};
}
@ -65,7 +84,7 @@ namespace BtcTransmuter.Extension.BtcPayServer.Triggers.InvoiceStatusChanged
BuildModel(
InvoiceStatusChangedTriggerViewModel viewModel, RecipeTrigger mainModel)
{
if (!ModelState.IsValid)
if (viewModel.Action != "EditData" || !ModelState.IsValid)
{
var btcPayServices = await _externalServiceManager.GetExternalServicesData(
new ExternalServicesDataQuery()
@ -73,12 +92,29 @@ namespace BtcTransmuter.Extension.BtcPayServer.Triggers.InvoiceStatusChanged
Type = new[] {BtcPayServerService.BtcPayServerServiceType},
UserId = GetUserId()
});
viewModel.Statuses = new SelectList(AllowedStatuses, "Value", "Text", viewModel.Status);
viewModel.ExternalServices = new SelectList(btcPayServices, nameof(ExternalServiceData.Id),
nameof(ExternalServiceData.Name), viewModel.ExternalServiceId);
return (null, viewModel);
if (viewModel.Action.StartsWith("add-condition", StringComparison.InvariantCultureIgnoreCase))
{
viewModel.Conditions.Add(new InvoiceStatusChangeCondition()
{
Status = GetAvailableStatuses(viewModel.Conditions.Select(condition => condition.Status).ToArray()).FirstOrDefault()?.Value?? Invoice.STATUS_NEW,
ExceptionStatuses = new List<string>()
{
Invoice.EXSTATUS_FALSE
}
});
}
if (viewModel.Action.StartsWith("remove-condition", StringComparison.InvariantCultureIgnoreCase))
{
var index = int.Parse(viewModel.Action.Substring(viewModel.Action.IndexOf(":", StringComparison.InvariantCultureIgnoreCase) + 1));
viewModel.Conditions.RemoveAt(index);
}
return (null, viewModel);
}
mainModel.ExternalServiceId = viewModel.ExternalServiceId;
@ -88,10 +124,10 @@ namespace BtcTransmuter.Extension.BtcPayServer.Triggers.InvoiceStatusChanged
public class InvoiceStatusChangedTriggerViewModel : InvoiceStatusChangedTriggerParameters
{
public string Action { get; set; }
public string RecipeId { get; set; }
public SelectList ExternalServices { get; set; }
[Required] public string ExternalServiceId { get; set; }
public SelectList Statuses { get; set; }
[Required][Display(Name = "BtcPay Service")] public string ExternalServiceId { get; set; }
}
}
}

View File

@ -2,11 +2,13 @@ using System;
using System.Threading.Tasks;
using BtcTransmuter.Abstractions.Triggers;
using BtcTransmuter.Data.Entities;
using NBitpayClient;
using Newtonsoft.Json.Linq;
namespace BtcTransmuter.Extension.BtcPayServer.Triggers.InvoiceStatusChanged
{
public class InvoiceStatusChangedTriggerHandler : BaseTriggerHandler<InvoiceStatusChangedTriggerData,
InvoiceStatusChangedTriggerParameters>
InvoiceStatusChangedTriggerParameters>
{
public override string TriggerId => new InvoiceStatusChangedTrigger().Id;
public override string Name => "BtcPayServer Invoice Status Change";
@ -15,19 +17,30 @@ namespace BtcTransmuter.Extension.BtcPayServer.Triggers.InvoiceStatusChanged
"Trigger a recipe by detecting a status change of an invoice in a btcpay external service.";
public override string ViewPartial => "ViewInvoiceStatusChangedTrigger";
protected override string ControllerName => "InvoiceStatusChanged";
public override string ControllerName => "InvoiceStatusChanged";
protected override Task<bool> IsTriggered(ITrigger trigger, RecipeTrigger recipeTrigger,
InvoiceStatusChangedTriggerData triggerData,
InvoiceStatusChangedTriggerParameters parameters)
{
if (string.IsNullOrEmpty(parameters.Status))
var exceptionStatus =Invoice.EXSTATUS_FALSE;
if (triggerData.Invoice.ExceptionStatus.Type == JTokenType.String)
{
return Task.FromResult(true);
exceptionStatus = triggerData.Invoice.ExceptionStatus.Value<string>();
}
var status = triggerData.Invoice.Status;
foreach (var condition in parameters.Conditions)
{
if (condition.Status.Equals(status, StringComparison.InvariantCultureIgnoreCase) &&
condition.ExceptionStatuses.Contains(exceptionStatus))
{
return Task.FromResult(true);
}
}
return Task.FromResult(triggerData.Invoice.Status.Equals(parameters.Status,
StringComparison.InvariantCultureIgnoreCase));
return Task.FromResult(false);
}
}
}

View File

@ -1,9 +1,22 @@
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using BtcTransmuter.Abstractions;
namespace BtcTransmuter.Extension.BtcPayServer.Triggers.InvoiceStatusChanged
{
public class InvoiceStatusChangedTriggerParameters
{
public string Status { get; set; }
public List<InvoiceStatusChangeCondition> Conditions { get; set; } = new List<InvoiceStatusChangeCondition>();
}
public class InvoiceStatusChangeCondition
{
[Required]
public string Status { get; set; }
[Display(Name = "Additional Statuses")]
[Required]
[EnsureMinimumElements(1, ErrorMessage = "At least one additional status is required")]
public List<string> ExceptionStatuses { get; set; }
}
}

View File

@ -0,0 +1,22 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
namespace BtcTransmuter.Extension.BtcPayServer.Validation
{
public class UriAttribute : ValidationAttribute
{
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
{
var str = value == null ? null : Convert.ToString(value, CultureInfo.InvariantCulture);
Uri uri;
bool valid = string.IsNullOrWhiteSpace(str) || Uri.TryCreate(str, UriKind.Absolute, out uri);
if (!valid)
{
return new ValidationResult(ErrorMessage);
}
return ValidationResult.Success;
}
}
}

View File

@ -9,13 +9,14 @@
<form method="post">
<div asp-validation-summary="All" class="text-danger"></div>
<div class="form-group">
<label asp-for="Server" class="control-label"></label>
<input asp-for="Server" class="form-control"/>
<span asp-validation-for="Server" class="text-danger"></span>
</div>
@if (!Model.Paired)
{
<div class="form-group">
<label asp-for="Server" class="control-label"></label>
<input asp-for="Server" class="form-control"/>
<span asp-validation-for="Server" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="PairingCode" class="control-label"></label>
<input asp-for="PairingCode" class="form-control"/>
@ -24,12 +25,17 @@
if (!string.IsNullOrEmpty(Model.PairingUrl))
{
<span>Authorize Client </span>
<span>Authorize Client </span>
<a href="@Model.PairingUrl" target="_blank"> @Model.PairingUrl</a>
}
}
else
{
<div class="form-group">
<label asp-for="Server" class="control-label"></label>
<input asp-for="Server" class="form-control" readonly="readonly"/>
<span asp-validation-for="Server" class="text-danger"></span>
</div>
<div class="alert alert-success"> Currently Paired</div>
}
<input type="hidden" name="Seed" value="@Model.Seed"/>
@ -39,7 +45,10 @@
{
<button type="submit" value="unpair" name="action" class="btn btn-danger">Unpair</button>
}
<button type="submit" class="btn btn-primary">Save</button>
else
{
<button type="submit" class="btn btn-primary">Save</button>
}
<a asp-action="GetServices" asp-controller="ExternalServices" class="btn btn-secondary">Back to recipe</a>
</div>
</form>

View File

@ -0,0 +1,36 @@
@using Microsoft.EntityFrameworkCore.Internal
@model BtcTransmuter.Extension.BtcPayServer.Actions.GetInvoice.GetInvoiceController.GetInvoiceViewModel
@{
ViewData["Title"] = "Edit Get Btcpay Invoice Action";
}
<h2>@ViewData["Title"]</h2>
<form method="post">
<div asp-validation-summary="All" class="text-danger"></div>
<div class="form-group">
<label asp-for="ExternalServiceId" class="control-label"></label>
<select asp-for="ExternalServiceId" asp-items="Model.ExternalServices" class="form-control"></select>
<span asp-validation-for="ExternalServiceId" class="text-danger"></span>
@if (!Model.ExternalServices.Items.Any())
{
<span class="text-danger">There are no BtcPay external services available to create this action. <a asp-action="CreateExternalService" asp-controller="ExternalServices">Create one</a></span>
}
</div>
<div class="form-group">
<label asp-for="InvoiceId" class="control-label"></label>
<input asp-for="InvoiceId" class="form-control" />
<span asp-validation-for="InvoiceId" class="text-danger"></span>
</div>
<input type="hidden" asp-for="RecipeId"/>
<div class="mt-2">
<button type="submit" class="btn btn-primary">Save</button>
<a asp-action="EditRecipe" asp-controller="Recipes" class="btn btn-secondary" asp-route-id="@Model.RecipeId">Back to recipe</a>
</div>
</form>
@await Component.InvokeAsync("RecipeActionFooter", new
{
recipeId = @Model.RecipeId,
recipeActionIdInGroupBeforeThisOne = @Model.RecipeActionIdInGroupBeforeThisOne
})

View File

@ -0,0 +1,46 @@
@using Microsoft.EntityFrameworkCore.Internal
@model BtcTransmuter.Extension.BtcPayServer.Actions.GetPaymentsFromInvoice.GetPaymentsFromInvoiceController.GetPaymentsFromInvoiceViewModel
@{
ViewData["Title"] = "Edit Get Payment for Btcpay Invoice Action";
}
<h2>@ViewData["Title"]</h2>
<form method="post">
<div asp-validation-summary="All" class="text-danger"></div>
<div class="form-group">
<label asp-for="ExternalServiceId" class="control-label"></label>
<select asp-for="ExternalServiceId" asp-items="Model.ExternalServices" class="form-control"></select>
<span asp-validation-for="ExternalServiceId" class="text-danger"></span>
@if (!Model.ExternalServices.Items.Any())
{
<span class="text-danger">There are no BtcPay external services available to create this action. <a asp-action="CreateExternalService" asp-controller="ExternalServices">Create one</a></span>
}
</div>
<div class="form-group">
<label asp-for="CryptoCode" class="control-label"></label>
<input asp-for="CryptoCode" class="form-control" />
<span asp-validation-for="CryptoCode" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="InvoiceId" class="control-label"></label>
<input asp-for="InvoiceId" class="form-control" />
<span asp-validation-for="InvoiceId" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="PaymentType" class="control-label"></label>
<select asp-for="PaymentType" asp-items="Model.PaymentTypes" class="form-control"></select>
<span asp-validation-for="PaymentType" class="text-danger"></span>
</div>
<input type="hidden" asp-for="RecipeId"/>
<div class="mt-2">
<button type="submit" class="btn btn-primary">Save</button>
<a asp-action="EditRecipe" asp-controller="Recipes" class="btn btn-secondary" asp-route-id="@Model.RecipeId">Back to recipe</a>
</div>
</form>
@await Component.InvokeAsync("RecipeActionFooter", new
{
recipeId = @Model.RecipeId,
recipeActionIdInGroupBeforeThisOne = @Model.RecipeActionIdInGroupBeforeThisOne
})

View File

@ -1,3 +1,4 @@
@using Microsoft.EntityFrameworkCore.Internal
@model BtcTransmuter.Extension.BtcPayServer.Triggers.InvoiceStatusChanged.InvoiceStatusChangedController.InvoiceStatusChangedTriggerViewModel
@ -14,15 +15,52 @@
<label asp-for="ExternalServiceId" class="control-label"></label>
<select asp-for="ExternalServiceId" asp-items="Model.ExternalServices" class="form-control"></select>
<span asp-validation-for="ExternalServiceId" class="text-danger"></span>
@if (!Model.ExternalServices.Items.Any())
{
<span class="text-danger">There are no BtcPay external services available to create this action. <a asp-action="CreateExternalService" asp-controller="ExternalServices">Create one</a></span>
}
</div>
<div class="form-group">
<label asp-for="Status" class="control-label"></label>
<select asp-for="Status" asp-items="Model.Statuses" class="form-control"></select>
<span asp-validation-for="Status" class="text-danger"></span>
<div class="list-group mb-2">
<div class="list-group-item ">
<h5 class="mb-1">Status Conditions</h5>
</div>
@for (var index = 0; index < Model.Conditions.Count; index++)
{
var statusCondition = Model.Conditions[index];
<div class="list-group-item justify-content-between align-items-center">
<div class="row">
<div class="form-group col-sm-12 col-md-6">
<label asp-for="Conditions[index].Status" class="control-label"></label>
<select asp-for="Conditions[index].Status"
asp-items="@(new SelectList(BtcTransmuter.Extension.BtcPayServer.Triggers.InvoiceStatusChanged.InvoiceStatusChangedController.AllowedStatuses, "Value", "Text", statusCondition.Status))" class="form-control">
</select>
<span asp-validation-for="Conditions[index].Status" class="text-danger"></span>
</div>
<div class="form-group col-sm-12 col-md-6">
<label asp-for="Conditions[index].ExceptionStatuses" class="control-label"></label>
<select asp-for="Conditions[index].ExceptionStatuses"
asp-items="@(new SelectList(BtcTransmuter.Extension.BtcPayServer.Triggers.InvoiceStatusChanged.InvoiceStatusChangedController.AllowedExceptionStatus, "Value", "Text", statusCondition.ExceptionStatuses))"
multiple="multiple"
class="form-control">
</select>
<span asp-validation-for="Conditions[index].ExceptionStatuses" class="text-danger"></span>
</div>
</div>
<div>
<button type="submit" name="action" value="@($"remove-condition:{index}")" class="btn btn-danger">Remove</button>
</div>
</div>
}
<div class="list-group-item ">
<button type="submit" name="action" value="add-condition" class="btn btn-secondary">Add</button>
</div>
</div>
<input type="hidden" asp-for="RecipeId" />
<div class="mt-2">
<button type="submit" class="btn btn-primary">Save</button>
<button type="submit" name="" value="" class="btn btn-primary">Save</button>
<a asp-action="EditRecipe" asp-controller="Recipes" class="btn btn-secondary" asp-route-id="@Model.RecipeId">Back to recipe</a>
</div>
</form>

View File

@ -0,0 +1,9 @@
@using BtcTransmuter.Data.Models
@using BtcTransmuter.Extension.BtcPayServer.Actions.GetInvoice
@model BtcTransmuter.Data.Entities.RecipeAction
@{
var data = Model.Get<GetInvoiceData>();
}
<div>
Get BtcPay invoice <kbd>@data.InvoiceId</kbd>
</div>

View File

@ -0,0 +1,9 @@
@using BtcTransmuter.Data.Models
@using BtcTransmuter.Extension.BtcPayServer.Actions.GetPaymentsFromInvoice
@model BtcTransmuter.Data.Entities.RecipeAction
@{
var data = Model.Get<GetPaymentsFromInvoiceData>();
}
<div>
Get <kbd>@data.CryptoCode @data.PaymentType</kbd>payments of BTCPay invoice <kbd>@data.InvoiceId</kbd>
</div>

View File

@ -6,10 +6,15 @@
}
<div>
Btcpayserver Invoice Status Change
@if (!string.IsNullOrEmpty(data.Status))
{
<span>to @data.Status</span>
}
Btcpayserver Invoice Status Change to
<kbd>
@if (data.Conditions.Any())
{
@string.Join(" or ", data.Conditions.Select(condition => $"{condition.Status}({string.Join(" or ", condition.ExceptionStatuses)})"))
}
else
{
<span>Not configured</span>
}
</kbd>
</div>

View File

@ -0,0 +1 @@
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

View File

@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="Moq" Version="4.14.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BtcTransmuter.Extension.DynamicServices\BtcTransmuter.Extension.DynamicServices.csproj" />
<ProjectReference Include="..\BtcTransmuter.Tests.Base\BtcTransmuter.Tests.Base.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,15 @@
using BtcTransmuter.Extension.Webhook.Triggers.DynamicServiceMarker;
using BtcTransmuter.Tests.Base;
namespace BtcTransmuter.Extension.DynamicServices.Tests
{
public class DynamicServiceMarkerTriggerHandlerTests : BaseTriggerTest<DynamicServiceMarkerTriggerHandler,
DynamicServiceMarkerTriggerData,
DynamicServiceMarkerTriggerParameters>
{
protected override DynamicServiceMarkerTriggerHandler GetTriggerHandlerInstance(params object[] setupArgs)
{
return new DynamicServiceMarkerTriggerHandler();
}
}
}

View File

@ -0,0 +1,58 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using BtcTransmuter.Abstractions.Actions;
using BtcTransmuter.Abstractions.ExternalServices;
using BtcTransmuter.Abstractions.Helpers;
using BtcTransmuter.Abstractions.Recipes;
using BtcTransmuter.Data.Entities;
using BtcTransmuter.Extension.BtcPayServer.ExternalServices.BtcPayServer;
using BtcTransmuter.Extension.DynamicService.ExternalServices.DynamicService;
using BtcTransmuter.Extension.Lightning.ExternalServices.NBXplorerWallet;
using BtcTransmuter.Extension.NBXplorer.Services;
using BtcTransmuter.Tests.Base;
using Microsoft.Extensions.DependencyInjection;
using Xunit;
namespace BtcTransmuter.Extension.DynamicServices.Tests
{
public class
DynamicServiceServiceTests : BaseExternalServiceTest<DynamicServiceService, DynamicServiceExternalServiceData>
{
public override Task CanSerializeData()
{
ConfigureDependencyHelper();
using (var scope = DependencyHelper.ServiceScopeFactory.CreateScope())
{
var x = GetExternalService();
var instance = new DynamicServiceExternalServiceData();
var externalService = GetExternalService(new ExternalServiceData()
{
Type = x.ExternalServiceType
},
scope.ServiceProvider.GetRequiredService<IRecipeManager>(),
scope.ServiceProvider.GetRequiredService<IActionDispatcher>(),
scope.ServiceProvider.GetRequiredService<IExternalServiceManager>()
);
externalService.SetData(instance);
externalService.GetData();
}
return Task.CompletedTask;
}
protected override DynamicServiceService GetExternalService(params object[] setupArgs)
{
if (setupArgs?.Any()?? false)
{
return new DynamicServiceService(
(ExternalServiceData) setupArgs.First(o => o is ExternalServiceData),
(IRecipeManager) setupArgs.First(o => o is IRecipeManager),
(IActionDispatcher) setupArgs.First(o => o is IActionDispatcher),
(IExternalServiceManager) setupArgs.First(o => o is IExternalServiceManager));
}
return new DynamicServiceService();
}
}
}

View File

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
<OutputType>Library</OutputType>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\BtcTransmuter.Abstractions\BtcTransmuter.Abstractions.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.4" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,9 @@
using BtcTransmuter.Abstractions.Extensions;
namespace BtcTransmuter.Extension.DynamicServices
{
public class DynamicServicesBtcTransmuterExtension : BtcTransmuterExtension
{
public override string Name => "Dynamic Services Plugin";
}
}

View File

@ -0,0 +1,94 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using BtcTransmuter.Abstractions.ExternalServices;
using BtcTransmuter.Abstractions.Recipes;
using BtcTransmuter.Data.Entities;
using BtcTransmuter.Data.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.Extensions.Caching.Memory;
namespace BtcTransmuter.Extension.DynamicService.ExternalServices.DynamicService
{
[Route("DynamicService-plugin/external-services/DynamicService")]
[Authorize]
public class DynamicServiceController : BaseExternalServiceController<EditDynamicServiceDataViewModel>
{
private readonly UserManager<User> _userManager;
private readonly IRecipeManager _recipeManager;
public DynamicServiceController(IExternalServiceManager externalServiceManager, UserManager<User> userManager,
IMemoryCache memoryCache, IRecipeManager recipeManager) : base(externalServiceManager, userManager, memoryCache)
{
_userManager = userManager;
_recipeManager = recipeManager;
}
protected override string ExternalServiceType => DynamicServiceService.DynamicServiceServiceType;
protected override async Task<EditDynamicServiceDataViewModel> BuildViewModel(ExternalServiceData data)
{
var client = new DynamicServiceService(data, null, null, null);
var clientData = client.GetData();
var recipes = await _recipeManager.GetRecipes(new RecipesQuery()
{
UserId = _userManager.GetUserId(User)
});
var recipe = string.IsNullOrEmpty(clientData.RecipeId)
? null
: recipes.SingleOrDefault(recipe1 =>
recipe1.Id.Equals(clientData.RecipeId, StringComparison.InvariantCultureIgnoreCase));
return new EditDynamicServiceDataViewModel()
{
Value = clientData.Value,
RecipeId = clientData.RecipeId,
RecipeActionId = clientData.RecipeActionId,
RecipeActionGroupId = clientData.RecipeActionGroupId,
Recipes = new SelectList(recipes, nameof(Recipe.Id), nameof(Recipe.Name), clientData.RecipeId),
RecipeActions =recipe == null? null : new SelectList(recipe.RecipeActions, nameof(RecipeAction.Id), nameof(RecipeAction.ActionId), clientData.RecipeActionId),
RecipeActionGroups = recipe == null? null : new SelectList(recipe.RecipeActionGroups, nameof(RecipeActionGroup.Id), nameof(RecipeActionGroup.Id), clientData.RecipeActionGroupId),
};
}
protected override async Task<(ExternalServiceData ToSave, EditDynamicServiceDataViewModel showViewModel)>
BuildModel(EditDynamicServiceDataViewModel viewModel, ExternalServiceData mainModel)
{
if (string.IsNullOrEmpty(viewModel.RecipeActionId) && string.IsNullOrEmpty(viewModel.RecipeActionGroupId))
{
ModelState.AddModelError(string.Empty, "please select a recipe action or a recipe action group ");
}
if (!ModelState.IsValid)
{
var recipes = await _recipeManager.GetRecipes(new RecipesQuery()
{
UserId = _userManager.GetUserId(User)
});
var recipe = string.IsNullOrEmpty(viewModel.RecipeId)
? null
: recipes.SingleOrDefault(recipe1 =>
recipe1.Id.Equals(viewModel.RecipeId, StringComparison.InvariantCultureIgnoreCase));
return (null, new EditDynamicServiceDataViewModel()
{
Value = viewModel.Value,
RecipeId = viewModel.RecipeId,
RecipeActionId = viewModel.RecipeActionId,
RecipeActionGroupId = viewModel.RecipeActionGroupId,
Recipes = new SelectList(recipes, nameof(Recipe.Id), nameof(Recipe.Name), viewModel.RecipeId),
RecipeActions =recipe == null? null : new SelectList(recipe.RecipeActions, nameof(RecipeAction.Id), nameof(RecipeAction.ActionId), viewModel.RecipeActionId),
RecipeActionGroups = recipe == null? null : new SelectList(recipe.RecipeActionGroups, nameof(RecipeActionGroup.Id), nameof(RecipeActionGroup.Id), viewModel.RecipeActionGroupId),
});
}
mainModel.Set(viewModel);
return (mainModel, null);
}
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace BtcTransmuter.Extension.DynamicService.ExternalServices.DynamicService
{
public class DynamicServiceExternalServiceData
{
public string RecipeId { get; set; }
public string RecipeActionId { get; set; }
public string RecipeActionGroupId { get; set; }
public string Value { get; set; }
}
}

View File

@ -0,0 +1,90 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BtcTransmuter.Abstractions.Actions;
using BtcTransmuter.Abstractions.ExternalServices;
using BtcTransmuter.Abstractions.Helpers;
using BtcTransmuter.Abstractions.Recipes;
using BtcTransmuter.Data.Entities;
namespace BtcTransmuter.Extension.DynamicService.ExternalServices.DynamicService
{
public class DynamicServiceService : BaseExternalService<DynamicServiceExternalServiceData>
{
private readonly ExternalServiceData _data;
private readonly IRecipeManager _recipeManager;
private readonly IActionDispatcher _actionDispatcher;
private readonly IExternalServiceManager _externalServiceManager;
public const string DynamicServiceServiceType = "DynamicServiceExternalService";
public override string ExternalServiceType => DynamicServiceServiceType;
public override string Name => "DynamicService External Service";
public override string Description =>
"DynamicService External Service to be able to resolve other external services using actions";
public override string ViewPartial => "ViewDynamicServiceExternalService";
public override string ControllerName => "DynamicService";
public DynamicServiceService() : base()
{
}
public DynamicServiceService(ExternalServiceData data, IRecipeManager recipeManager,
IActionDispatcher actionDispatcher, IExternalServiceManager externalServiceManager) : base(data)
{
_data = data;
_recipeManager = recipeManager;
_actionDispatcher = actionDispatcher;
_externalServiceManager = externalServiceManager;
}
public async Task<ExternalServiceData> ExecuteWitchcraftToComputeExternalService()
{
var data = GetData();
var recipe = await _recipeManager.GetRecipe(data.RecipeId);
if (recipe == null)
{
return null;
}
var actionData = new Dictionary<string, (object data, string json)>();
if (!string.IsNullOrEmpty(data.RecipeActionId))
{
var recipeAction = recipe.RecipeActions.SingleOrDefault(action =>
action.Id.Equals(data.RecipeActionId, StringComparison.InvariantCultureIgnoreCase));
if (recipeAction == null)
{
return null;
}
var dispatchResult = await _actionDispatcher.Dispatch(actionData,
recipeAction);
actionData.Add("PreviousAction", (dispatchResult.First().Data, dispatchResult.First().DataJson));
actionData.Add("ActionData0", (dispatchResult.First().Data, dispatchResult.First().DataJson));
}
if (!string.IsNullOrEmpty(data.RecipeActionGroupId))
{
var recipeActionGroup = recipe.RecipeActionGroups.SingleOrDefault(action =>
action.Id.Equals(data.RecipeActionGroupId, StringComparison.InvariantCultureIgnoreCase));
if (recipeActionGroup == null)
{
return null;
}
await _actionDispatcher.Dispatch(actionData,
recipeActionGroup);
}
var value = InterpolationHelper.InterpolateString(data.Value,
actionData.ToDictionary(pair => pair.Key, pair => pair.Value.data));
return await _externalServiceManager.GetExternalServiceData(value, _data.UserId);
}
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Mvc.Rendering;
namespace BtcTransmuter.Extension.DynamicService.ExternalServices.DynamicService
{
public class EditDynamicServiceDataViewModel : DynamicServiceExternalServiceData
{
public string Action { get; set; }
public SelectList Recipes { get; set; }
public SelectList RecipeActions { get; set; }
public SelectList RecipeActionGroups { get; set; }
}
}

View File

@ -0,0 +1,33 @@
using System;
using System.Threading.Tasks;
using BtcTransmuter.Abstractions.Actions;
using BtcTransmuter.Abstractions.ExternalServices;
using BtcTransmuter.Abstractions.Helpers;
using BtcTransmuter.Abstractions.Recipes;
using BtcTransmuter.Data.Entities;
using BtcTransmuter.Extension.DynamicService.ExternalServices.DynamicService;
using Microsoft.Extensions.DependencyInjection;
namespace BtcTransmuter.Extension.DynamicServices
{
public static class RecipeActionExtensions
{
public static async Task<ExternalServiceData> GetExternalService(this RecipeAction recipeAction)
{
if (recipeAction.ExternalService == null || !recipeAction.ExternalService.Type.Equals(
DynamicServiceService.DynamicServiceServiceType, StringComparison.InvariantCultureIgnoreCase))
return recipeAction.ExternalService;
using (var scope = DependencyHelper.ServiceScopeFactory.CreateScope())
{
var service = new DynamicServiceService(recipeAction.ExternalService,
scope.ServiceProvider.GetService<IRecipeManager>(),
scope.ServiceProvider.GetService<IActionDispatcher>(),
scope.ServiceProvider.GetService<IExternalServiceManager>());
return await service.ExecuteWitchcraftToComputeExternalService();
}
}
}
}

View File

@ -0,0 +1,45 @@
using System.Threading.Tasks;
using BtcTransmuter.Abstractions.ExternalServices;
using BtcTransmuter.Abstractions.Recipes;
using BtcTransmuter.Abstractions.Triggers;
using BtcTransmuter.Data.Entities;
using BtcTransmuter.Data.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory;
namespace BtcTransmuter.Extension.Webhook.Triggers.DynamicServiceMarker
{
[Authorize]
[Route("DynamicService-plugin/triggers/[controller]")]
public class DynamicServiceMarkerController : BaseTriggerController<DynamicServiceMarkerTriggerParametersViewModel, DynamicServiceMarkerTriggerParameters>
{
public DynamicServiceMarkerController(IRecipeManager recipeManager, UserManager<User> userManager,
IMemoryCache memoryCache,
IExternalServiceManager externalServiceManager) : base(recipeManager, userManager, memoryCache,
externalServiceManager)
{
}
protected override Task<DynamicServiceMarkerTriggerParametersViewModel> BuildViewModel(RecipeTrigger data)
{
return Task.FromResult(new DynamicServiceMarkerTriggerParametersViewModel()
{
RecipeId = data.RecipeId
});
}
protected override Task<(RecipeTrigger ToSave, DynamicServiceMarkerTriggerParametersViewModel showViewModel)> BuildModel(
DynamicServiceMarkerTriggerParametersViewModel viewModel, RecipeTrigger mainModel)
{
mainModel.Set(viewModel);
return Task.FromResult<(RecipeTrigger ToSave, DynamicServiceMarkerTriggerParametersViewModel showViewModel)>((mainModel,
null));
}
}
}

View File

@ -0,0 +1,8 @@
using BtcTransmuter.Abstractions.Triggers;
namespace BtcTransmuter.Extension.Webhook.Triggers.DynamicServiceMarker
{
public class DynamicServiceMarkerTrigger : BaseTrigger<DynamicServiceMarkerTriggerData>
{
}
}

View File

@ -0,0 +1,9 @@
using System.Net.Http;
namespace BtcTransmuter.Extension.Webhook.Triggers.DynamicServiceMarker
{
public class DynamicServiceMarkerTriggerData
{
}
}

Some files were not shown because too many files have changed in this diff Show More