From 05dbc617d4921e3ffcbdc97366367b989f87d188 Mon Sep 17 00:00:00 2001 From: turcol Date: Wed, 4 Aug 2021 11:00:49 -0400 Subject: [PATCH 1/7] Add OpReturnDataIsHex in build-tx-request to store hex bytes --- .../Api/Controllers/WalletController.cs | 18 ++++++++++++++++++ .../Api/Models/RequestModels.cs | 5 +++++ 2 files changed, 23 insertions(+) diff --git a/src/Features/Blockcore.Features.Wallet/Api/Controllers/WalletController.cs b/src/Features/Blockcore.Features.Wallet/Api/Controllers/WalletController.cs index ebb573eef..f53679f9f 100644 --- a/src/Features/Blockcore.Features.Wallet/Api/Controllers/WalletController.cs +++ b/src/Features/Blockcore.Features.Wallet/Api/Controllers/WalletController.cs @@ -23,6 +23,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using NBitcoin; +using NBitcoin.DataEncoders; namespace Blockcore.Features.Wallet.Api.Controllers { @@ -698,6 +699,10 @@ public IActionResult BuildTransaction([FromBody] BuildTransactionRequest request } } + var (opReturnRawData, isValid) = request.OpReturnDataIsHex ? TryGetHexValue(request.OpReturnData) : (null, true); + if (!isValid) + return ErrorHelpers.BuildErrorResponse(HttpStatusCode.BadRequest, "Hex OpReturn error.", "The OpReturnData is set as a hex value and could not be decoded"); + var context = new TransactionBuildContext(this.network) { AccountReference = new WalletAccountReference(request.WalletName, request.AccountName), @@ -705,6 +710,7 @@ public IActionResult BuildTransaction([FromBody] BuildTransactionRequest request MinConfirmations = request.AllowUnconfirmed ? 0 : 1, Shuffle = request.ShuffleOutputs ?? true, // We shuffle transaction outputs by default as it's better for anonymity. OpReturnData = request.OpReturnData, + OpReturnRawData = opReturnRawData, OpReturnAmount = string.IsNullOrEmpty(request.OpReturnAmount) ? null : Money.Parse(request.OpReturnAmount), WalletPassword = request.Password, SelectedInputs = request.Outpoints?.Select(u => new OutPoint(uint256.Parse(u.TransactionId), u.Index)).ToList(), @@ -1602,5 +1608,17 @@ private void SyncFromBestHeightForRecoveredWallets(DateTime walletCreationDate) this.walletSyncManager.SyncFromHeight(blockHeightToSyncFrom); } } + + private (byte[], bool) TryGetHexValue(string hexString) + { + try + { + return (Encoders.Hex.DecodeData(hexString), true); + } + catch + { + return (null, false); + } + } } } \ No newline at end of file diff --git a/src/Features/Blockcore.Features.Wallet/Api/Models/RequestModels.cs b/src/Features/Blockcore.Features.Wallet/Api/Models/RequestModels.cs index e36cdce11..31b59fb65 100644 --- a/src/Features/Blockcore.Features.Wallet/Api/Models/RequestModels.cs +++ b/src/Features/Blockcore.Features.Wallet/Api/Models/RequestModels.cs @@ -328,6 +328,11 @@ public TxFeeEstimateRequest() /// public string OpReturnData { get; set; } + /// + /// Sets if the OpReturnData is a hex value and must be decoded + /// + public bool OpReturnDataIsHex { get; set; } + /// /// The funds in STRAT (or a sidechain coin) to include with the OP_RETURN output. Currently, specifying /// some funds helps OP_RETURN outputs be relayed around the network. From b5f9fb6f159867e18826cdd8eb47f1cf82791a1c Mon Sep 17 00:00:00 2001 From: turcol Date: Wed, 4 Aug 2021 11:24:42 -0400 Subject: [PATCH 2/7] Update checkpoints --- src/Networks/Blockcore.Networks.OpenExo/OpenExoSetup.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Networks/Blockcore.Networks.OpenExo/OpenExoSetup.cs b/src/Networks/Blockcore.Networks.OpenExo/OpenExoSetup.cs index cfbd11538..8c892f79b 100644 --- a/src/Networks/Blockcore.Networks.OpenExo/OpenExoSetup.cs +++ b/src/Networks/Blockcore.Networks.OpenExo/OpenExoSetup.cs @@ -81,7 +81,13 @@ internal class OpenExoSetup { 450000, new CheckpointInfo(new uint256("0xfaa749cba84d1111affe61cb8c14ba43a452a265a136066554a22cfa14cabfcd"), new uint256("0x651884ceb30069212c90b5fb3a11d2e6263c0a5c76d6b9b92274ffd6cb3b8fea")) }, { 600000, new CheckpointInfo(new uint256("0xa4bf14b94da99b72abafb66624e0f238bef68f9141f79f811f618d67bd8149d1"), new uint256("0x99199a7ac240838d58e362e834e43fc52b74e146f84ce3d879d4c213a4799745")) }, { 790000, new CheckpointInfo(new uint256("0x11610eefff99c06e8fe4667adb07f8598c339ed04e6eed5414b115fb7d4cfd49"), new uint256("0x46cb091b43846e21b547ebf3787deab210628919421180d4cc8275d276fe1cda")) } - + { 900000, new CheckpointInfo(new uint256("0x960369823996b14b7f08b876e8f95378119831ce81a72886434c9fd41d04c580"), new uint256("0x019aec9d3716f63d5c645b860b752e1699f176eaa4830e2daeb4fa1831b119d1")) }, + { 1000000, new CheckpointInfo(new uint256("0x1a1fc554ec11796d1c98a674ebd419db9abeba14419b97964f3ce357986d0350"), new uint256("0x8f9b2589afadc9e1f56e6cc216f3feb267339a825b9fcbb36f25c90edac8f0bd")) }, + { 1300000, new CheckpointInfo(new uint256("0x260b7433a7c72694f57f2e0ea6821f5ab33afea3c567f9845c8a989eb443f9d4"), new uint256("0x79f20f2a22bb3c8a0808e6d5e0daa7d8ce0ecbefcd1d842fa2e5a23e14b22d45")) }, + { 1355000, new CheckpointInfo(new uint256("0x890101f0f9b4c16c39eafeca5aa744772b7612eb003583200a5836cbb0acb332"), new uint256("0x5c34eb0ef4759118e720bdc57a72ffe4d8d4048e2706d053f420e2a2c399fe6c")) }, + { 1401000, new CheckpointInfo(new uint256("0x9eb2e4d7650f401e5d27af3fd66848c3318e7a2a660d44b3c8196ab0c956e074"), new uint256("0xff4fd825959265782056f501e68406dcc50e2fe9bc9f82d773f26a6318cf1529"))}, + { 1464600, new CheckpointInfo(new uint256("0xb2fbdc8e6d87a8a3a5322e32939fb9c1c06527f5edfc818a500122985360763e"), new uint256("0x364d3e3cfe66fced6b101d8240106af46b951c500b20223b0ea23c47d51127ea"))} + { 1567000, new CheckpointInfo(new uint256("0xd2bd6c7a2dec44a739d25cc669245107a97474abcfc8f94367fcbd19b829d28f"), new uint256("0x60c7ae802655cc063061e9d15a05444db0aa742f54dde3f4bdbca70670792737"))} } }; From 7fab59928a6811592c6e40625e4a718783c40942 Mon Sep 17 00:00:00 2001 From: turcol Date: Wed, 4 Aug 2021 18:29:52 -0400 Subject: [PATCH 3/7] Update checkpoints Rutanio --- src/Networks/Blockcore.Networks.Rutanio/RutanioSetup.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Networks/Blockcore.Networks.Rutanio/RutanioSetup.cs b/src/Networks/Blockcore.Networks.Rutanio/RutanioSetup.cs index 28dd49d06..070b324e8 100644 --- a/src/Networks/Blockcore.Networks.Rutanio/RutanioSetup.cs +++ b/src/Networks/Blockcore.Networks.Rutanio/RutanioSetup.cs @@ -73,6 +73,9 @@ internal class RutanioSetup { 200000, new CheckpointInfo(new uint256("0xf1c63ee81dbdd9a419d75d74c1bfcef1a1d135745bf83d3c263ee77f0533d0bf"), new uint256("0x44c40d7991b88d56eea10154e32cd5c10087094f4f831b79be2c5dcfb085ee71")) }, { 309000, new CheckpointInfo(new uint256("0x7e24a192fdfc29290a831cdc10a6adcfb55dfb457de1b5ed00d0a13ffa2ead17"), new uint256("0x01c332d8310b5d165aa64cd0a70849143c23b04b2689a5523d1f7dd52f670bc6")) }, { 475000, new CheckpointInfo(new uint256("0x502700a3ab205f8e7120dcfad7d982dc30b3067f529e712032c724d8a21d7482"), new uint256("0x6bff1fd82fd6c13799c614f44b8f785e7ba976d1ff082a165309bac6e72dfd43")) } + { 500000, new CheckpointInfo(new uint256("0xc128acd15b2a6d2d17a30ef251677fd7580bb78e5954f589ff438c607995d44b"), new uint256("0x7513e311fe01cf69da8d77ffd5f31b38ec899cb2c49ae320bf5e2ac1e3b88f71")) } + { 700000, new CheckpointInfo(new uint256("0x30b6030252cb34146a1e9f86bde5724200442b249f7f2460364c9864f9a7fc06"), new uint256("0xa6f63b8a4de53fe866f279caa0657a99d51f59fcf6f20525892550347e638e03")) } + { 951000, new CheckpointInfo(new uint256("0x4a67de08b5e15d170832a0bc37e880d32adca39844be41a5d2767d019a98894e"), new uint256("0x79eaf1dae3e97a9c3a4e8e830918c95dfbf742f5c29f2552b219465b7ce0dd42")) } } }; From 9248e77db6b5d3455b4d2d0cae1cc14556df435a Mon Sep 17 00:00:00 2001 From: turcol Date: Wed, 4 Aug 2021 20:18:45 -0400 Subject: [PATCH 4/7] Add missing comma at the EOL --- src/Networks/Blockcore.Networks.Rutanio/RutanioSetup.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Networks/Blockcore.Networks.Rutanio/RutanioSetup.cs b/src/Networks/Blockcore.Networks.Rutanio/RutanioSetup.cs index 070b324e8..d4dfaffb4 100644 --- a/src/Networks/Blockcore.Networks.Rutanio/RutanioSetup.cs +++ b/src/Networks/Blockcore.Networks.Rutanio/RutanioSetup.cs @@ -72,9 +72,9 @@ internal class RutanioSetup { 150000, new CheckpointInfo(new uint256("0xcab87f808e59ff30e8c741df899f993bb9b30cc78f0438a6c1ffac04abf9f124"), new uint256("0x201fd57cd71bbcf604ecb73a9770ded4210b046d857d5ce7865f2fa0e5e5c98e")) }, { 200000, new CheckpointInfo(new uint256("0xf1c63ee81dbdd9a419d75d74c1bfcef1a1d135745bf83d3c263ee77f0533d0bf"), new uint256("0x44c40d7991b88d56eea10154e32cd5c10087094f4f831b79be2c5dcfb085ee71")) }, { 309000, new CheckpointInfo(new uint256("0x7e24a192fdfc29290a831cdc10a6adcfb55dfb457de1b5ed00d0a13ffa2ead17"), new uint256("0x01c332d8310b5d165aa64cd0a70849143c23b04b2689a5523d1f7dd52f670bc6")) }, - { 475000, new CheckpointInfo(new uint256("0x502700a3ab205f8e7120dcfad7d982dc30b3067f529e712032c724d8a21d7482"), new uint256("0x6bff1fd82fd6c13799c614f44b8f785e7ba976d1ff082a165309bac6e72dfd43")) } - { 500000, new CheckpointInfo(new uint256("0xc128acd15b2a6d2d17a30ef251677fd7580bb78e5954f589ff438c607995d44b"), new uint256("0x7513e311fe01cf69da8d77ffd5f31b38ec899cb2c49ae320bf5e2ac1e3b88f71")) } - { 700000, new CheckpointInfo(new uint256("0x30b6030252cb34146a1e9f86bde5724200442b249f7f2460364c9864f9a7fc06"), new uint256("0xa6f63b8a4de53fe866f279caa0657a99d51f59fcf6f20525892550347e638e03")) } + { 475000, new CheckpointInfo(new uint256("0x502700a3ab205f8e7120dcfad7d982dc30b3067f529e712032c724d8a21d7482"), new uint256("0x6bff1fd82fd6c13799c614f44b8f785e7ba976d1ff082a165309bac6e72dfd43")) }, + { 500000, new CheckpointInfo(new uint256("0xc128acd15b2a6d2d17a30ef251677fd7580bb78e5954f589ff438c607995d44b"), new uint256("0x7513e311fe01cf69da8d77ffd5f31b38ec899cb2c49ae320bf5e2ac1e3b88f71")) }, + { 700000, new CheckpointInfo(new uint256("0x30b6030252cb34146a1e9f86bde5724200442b249f7f2460364c9864f9a7fc06"), new uint256("0xa6f63b8a4de53fe866f279caa0657a99d51f59fcf6f20525892550347e638e03")) }, { 951000, new CheckpointInfo(new uint256("0x4a67de08b5e15d170832a0bc37e880d32adca39844be41a5d2767d019a98894e"), new uint256("0x79eaf1dae3e97a9c3a4e8e830918c95dfbf742f5c29f2552b219465b7ce0dd42")) } } }; From e1bd2964f7b40e9aa6bafed119e85959d52cb317 Mon Sep 17 00:00:00 2001 From: Sondre Date: Tue, 17 Aug 2021 13:54:15 +0200 Subject: [PATCH 5/7] Remove modifications that has been added in separate PR #348 --- .../Api/Controllers/WalletController.cs | 19 +------------------ .../Api/Models/RequestModels.cs | 5 ----- 2 files changed, 1 insertion(+), 23 deletions(-) diff --git a/src/Features/Blockcore.Features.Wallet/Api/Controllers/WalletController.cs b/src/Features/Blockcore.Features.Wallet/Api/Controllers/WalletController.cs index f53679f9f..7b2543b46 100644 --- a/src/Features/Blockcore.Features.Wallet/Api/Controllers/WalletController.cs +++ b/src/Features/Blockcore.Features.Wallet/Api/Controllers/WalletController.cs @@ -699,10 +699,6 @@ public IActionResult BuildTransaction([FromBody] BuildTransactionRequest request } } - var (opReturnRawData, isValid) = request.OpReturnDataIsHex ? TryGetHexValue(request.OpReturnData) : (null, true); - if (!isValid) - return ErrorHelpers.BuildErrorResponse(HttpStatusCode.BadRequest, "Hex OpReturn error.", "The OpReturnData is set as a hex value and could not be decoded"); - var context = new TransactionBuildContext(this.network) { AccountReference = new WalletAccountReference(request.WalletName, request.AccountName), @@ -710,7 +706,6 @@ public IActionResult BuildTransaction([FromBody] BuildTransactionRequest request MinConfirmations = request.AllowUnconfirmed ? 0 : 1, Shuffle = request.ShuffleOutputs ?? true, // We shuffle transaction outputs by default as it's better for anonymity. OpReturnData = request.OpReturnData, - OpReturnRawData = opReturnRawData, OpReturnAmount = string.IsNullOrEmpty(request.OpReturnAmount) ? null : Money.Parse(request.OpReturnAmount), WalletPassword = request.Password, SelectedInputs = request.Outpoints?.Select(u => new OutPoint(uint256.Parse(u.TransactionId), u.Index)).ToList(), @@ -1607,18 +1602,6 @@ private void SyncFromBestHeightForRecoveredWallets(DateTime walletCreationDate) { this.walletSyncManager.SyncFromHeight(blockHeightToSyncFrom); } - } - - private (byte[], bool) TryGetHexValue(string hexString) - { - try - { - return (Encoders.Hex.DecodeData(hexString), true); - } - catch - { - return (null, false); - } - } + } } } \ No newline at end of file diff --git a/src/Features/Blockcore.Features.Wallet/Api/Models/RequestModels.cs b/src/Features/Blockcore.Features.Wallet/Api/Models/RequestModels.cs index 31b59fb65..e36cdce11 100644 --- a/src/Features/Blockcore.Features.Wallet/Api/Models/RequestModels.cs +++ b/src/Features/Blockcore.Features.Wallet/Api/Models/RequestModels.cs @@ -328,11 +328,6 @@ public TxFeeEstimateRequest() /// public string OpReturnData { get; set; } - /// - /// Sets if the OpReturnData is a hex value and must be decoded - /// - public bool OpReturnDataIsHex { get; set; } - /// /// The funds in STRAT (or a sidechain coin) to include with the OP_RETURN output. Currently, specifying /// some funds helps OP_RETURN outputs be relayed around the network. From fc37e22b6bee16e2b621cf047e1e194c1dc25b55 Mon Sep 17 00:00:00 2001 From: Sondre Date: Tue, 17 Aug 2021 13:55:01 +0200 Subject: [PATCH 6/7] Minor syntax change --- .../Api/Controllers/WalletController.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Features/Blockcore.Features.Wallet/Api/Controllers/WalletController.cs b/src/Features/Blockcore.Features.Wallet/Api/Controllers/WalletController.cs index 7b2543b46..ebb573eef 100644 --- a/src/Features/Blockcore.Features.Wallet/Api/Controllers/WalletController.cs +++ b/src/Features/Blockcore.Features.Wallet/Api/Controllers/WalletController.cs @@ -23,7 +23,6 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using NBitcoin; -using NBitcoin.DataEncoders; namespace Blockcore.Features.Wallet.Api.Controllers { @@ -1602,6 +1601,6 @@ private void SyncFromBestHeightForRecoveredWallets(DateTime walletCreationDate) { this.walletSyncManager.SyncFromHeight(blockHeightToSyncFrom); } - } + } } } \ No newline at end of file From 698a42558c086781851302982553043441b17346 Mon Sep 17 00:00:00 2001 From: Sondre Date: Tue, 17 Aug 2021 13:57:55 +0200 Subject: [PATCH 7/7] Remove OpenExo checkpoints that has been approved in #348 --- src/Networks/Blockcore.Networks.OpenExo/OpenExoSetup.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/Networks/Blockcore.Networks.OpenExo/OpenExoSetup.cs b/src/Networks/Blockcore.Networks.OpenExo/OpenExoSetup.cs index 8c892f79b..cfbd11538 100644 --- a/src/Networks/Blockcore.Networks.OpenExo/OpenExoSetup.cs +++ b/src/Networks/Blockcore.Networks.OpenExo/OpenExoSetup.cs @@ -81,13 +81,7 @@ internal class OpenExoSetup { 450000, new CheckpointInfo(new uint256("0xfaa749cba84d1111affe61cb8c14ba43a452a265a136066554a22cfa14cabfcd"), new uint256("0x651884ceb30069212c90b5fb3a11d2e6263c0a5c76d6b9b92274ffd6cb3b8fea")) }, { 600000, new CheckpointInfo(new uint256("0xa4bf14b94da99b72abafb66624e0f238bef68f9141f79f811f618d67bd8149d1"), new uint256("0x99199a7ac240838d58e362e834e43fc52b74e146f84ce3d879d4c213a4799745")) }, { 790000, new CheckpointInfo(new uint256("0x11610eefff99c06e8fe4667adb07f8598c339ed04e6eed5414b115fb7d4cfd49"), new uint256("0x46cb091b43846e21b547ebf3787deab210628919421180d4cc8275d276fe1cda")) } - { 900000, new CheckpointInfo(new uint256("0x960369823996b14b7f08b876e8f95378119831ce81a72886434c9fd41d04c580"), new uint256("0x019aec9d3716f63d5c645b860b752e1699f176eaa4830e2daeb4fa1831b119d1")) }, - { 1000000, new CheckpointInfo(new uint256("0x1a1fc554ec11796d1c98a674ebd419db9abeba14419b97964f3ce357986d0350"), new uint256("0x8f9b2589afadc9e1f56e6cc216f3feb267339a825b9fcbb36f25c90edac8f0bd")) }, - { 1300000, new CheckpointInfo(new uint256("0x260b7433a7c72694f57f2e0ea6821f5ab33afea3c567f9845c8a989eb443f9d4"), new uint256("0x79f20f2a22bb3c8a0808e6d5e0daa7d8ce0ecbefcd1d842fa2e5a23e14b22d45")) }, - { 1355000, new CheckpointInfo(new uint256("0x890101f0f9b4c16c39eafeca5aa744772b7612eb003583200a5836cbb0acb332"), new uint256("0x5c34eb0ef4759118e720bdc57a72ffe4d8d4048e2706d053f420e2a2c399fe6c")) }, - { 1401000, new CheckpointInfo(new uint256("0x9eb2e4d7650f401e5d27af3fd66848c3318e7a2a660d44b3c8196ab0c956e074"), new uint256("0xff4fd825959265782056f501e68406dcc50e2fe9bc9f82d773f26a6318cf1529"))}, - { 1464600, new CheckpointInfo(new uint256("0xb2fbdc8e6d87a8a3a5322e32939fb9c1c06527f5edfc818a500122985360763e"), new uint256("0x364d3e3cfe66fced6b101d8240106af46b951c500b20223b0ea23c47d51127ea"))} - { 1567000, new CheckpointInfo(new uint256("0xd2bd6c7a2dec44a739d25cc669245107a97474abcfc8f94367fcbd19b829d28f"), new uint256("0x60c7ae802655cc063061e9d15a05444db0aa742f54dde3f4bdbca70670792737"))} + } };