profile
viewpoint
Jonas Schnelli jonasschnelli Bitcoin Core Basel/Zurich Switzerland bitcoin.jonasschnelli.ch Bitcoin Core Developer & Maintainer

jonasschnelli/bitcoincore-indexd 34

p2p based txindex for Bitcoin

jonasschnelli/bitcoin-core-ci 13

Custom tailored continuous integration system based on KVM running on bitcoinbuilds.org

jonasschnelli/chacha20poly1305 12

Simple ChaCha20Poly1305@Bitcoin C implementation

bitcoin-core/bitcoin-detached-sigs 9

Bitcoin detached release signatures

jonasschnelli/corewatchpush 7

Watch a bunch of xpubs via Bitcoin Core and get notifications on new transactions

jonasschnelli/CLLocation-CH1903 4

iPhone: CLLocation Category (Extension) for handling CH1903 (Swiss) coordinates

jonasschnelli/bitcoin_txref_code 3

Confirmed Transaction Reference Code

jonasschnelli/cipherseed 3

Encrypted Bitcoin Seed

push eventbitcoin-core/gitian.sigs

Luke Dashjr

commit sha 0e087113004228e7403c33e17a189de0dfce7de2

luke-jr 0.21.0rc2

view details

push time in 2 hours

pull request commentbitcoin/bitcoin

ci, depends: Do not force Precompiled Headers (PCH) when building Qt

<!--e57a25ab6845829454e8d69fc972939a-->

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

<!--174a7506f384e20aa4161008e828411d-->

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #19716 (build: Qt 5.15.x by fanquake)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

hebasto

comment created time in 2 hours

pull request commentbitcoin/bitcoin

[test] Fix sync issue in disconnect_p2ps

the CI failure is a FileNotFoundError from feature_config_args, so seems unrelated

image

amitiuttarwar

comment created time in 3 hours

pull request commentbitcoin/bitcoin

[test] Fix sync issue in disconnect_p2ps

cc @glozow @jnewbery @MarcoFalke

amitiuttarwar

comment created time in 3 hours

PR opened bitcoin/bitcoin

[test] Fix sync issue in disconnect_p2ps

#19315 currently has a test failure because of a race. disconnect_p2ps is intended to have a wait_until clause that prevents this race, but the conditional doesn't match since its comparing two different object types. MY_SUBVERSION is defined in messages.py as a byte string, but is compared to the value returned by the RPC. This PR simply converts types to ensure they match, which should prevent the race from occurring.

+1 -1

0 comment

1 changed file

pr created time in 5 hours

pull request commentbitcoin/bitcoin

build: mac deployment unification

Kizoojun

fanquake

comment created time in 5 hours

pull request commentbitcoin/bitcoin

contrib: Parse ELF directly for symbol and security checks

<!--9cd9c72976c961c55c7acef8f6ba82cd-->

Guix builds

File commit afdfd3c8c1ce96adae11809e3989de381137fee9<br>(master) commit 2cc79521b7af3cce8118b2a04fbe257764c44708<br>(master and this pull)
*-aarch64-linux-gnu-debug.tar.gz 321e361023e8ea7b... 813144f84559e0dc...
*-aarch64-linux-gnu.tar.gz b054d1129516836e... 184917064f174e78...
*-arm-linux-gnueabihf-debug.tar.gz cdd6185a356e7a80... 883c572d0fe1a7db...
*-arm-linux-gnueabihf.tar.gz 4db9b1126b6601b7... 8f212d72c0159656...
*-riscv64-linux-gnu-debug.tar.gz df4a6eb0267f7140... 12e5d6bdec38909f...
*-riscv64-linux-gnu.tar.gz 3ff6d83bd5983e2b... e252e5ded636a464...
*-win-unsigned.tar.gz 0dbc83ed5f22a4db... 68b64bab11c74876...
*-win64-debug.zip 539b210aa13b56bc... 9f1868590f5c2034...
*-win64-setup-unsigned.exe 5ff779deff3db721... c3d72b942f3ed28a...
*-win64.zip 4e50c84031e8b116... c78d5b2dce8fab09...
*-x86_64-linux-gnu-debug.tar.gz 345daa571d3557b0... 32a8cd9a90d81191...
*-x86_64-linux-gnu.tar.gz 60655c6fb26e8633... 8a90973bb90f451b...
*.tar.gz 0ddcf17cb856ed92... d150e18f32cf35ab...
guix_build.log 6670400b0a6511d0... 1b9c8c06b0d5ed02...
guix_build.log.diff 70d1bc211652bbf4...
laanwj

comment created time in 5 hours

pull request commentbitcoin/bitcoin

build: mac deployment unification

Concept ACK!

fanquake

comment created time in 5 hours

pull request commentbitcoin-core/secp256k1

ecdsa sign-to-contract module, with anti nonce covert chan util functions

I think we can merge this into -zkp soon. I have https://github.com/ElementsProject/secp256k1-zkp/pull/111. If you do your own rebase it might be easier to start from that since I did the work of combing the new unified ecdsa/recovery code with this PR's implementation of the same thing.

benma

comment created time in 7 hours

pull request commentbitcoin-core/secp256k1

Safegcd inverses, drop Jacobi symbols, remove libgmp

@peterdettman Had to make these additional changes to satisfy ubsan (they were actually invoking UB, I believe):

diff --git a/src/modinv32.h b/src/modinv32.h
index 74fc3fd8..d46447b1 100644
--- a/src/modinv32.h
+++ b/src/modinv32.h
@@ -22,7 +22,7 @@ typedef struct {
     secp256k1_modinv32_signed30 modulus;
 
     /* modulus^{-1} mod 2^30 */
-    int32_t modulus_inv30;
+    uint32_t modulus_inv30;
 } secp256k1_modinv32_modinfo;
 
 static void secp256k1_modinv32(secp256k1_modinv32_signed30 *x, const secp256k1_modinv32_modinfo *modinfo);
diff --git a/src/modinv32_impl.h b/src/modinv32_impl.h
index 2cd65557..a15bd2f9 100644
--- a/src/modinv32_impl.h
+++ b/src/modinv32_impl.h
@@ -201,8 +201,8 @@ static void secp256k1_modinv32_update_de_30(secp256k1_modinv32_signed30 *d, secp
      * the range (-2.P, P), consistent with the input constraint.
      */
 
-    md -= (modinfo->modulus_inv30 * (int32_t)cd + md) & M30;
-    me -= (modinfo->modulus_inv30 * (int32_t)ce + me) & M30;
+    md -= (modinfo->modulus_inv30 * (uint32_t)cd + md) & M30;
+    me -= (modinfo->modulus_inv30 * (uint32_t)ce + me) & M30;
 
     /* The modulus has to be odd, so we can assume it is nonzero. */
     cd += (int64_t)modinfo->modulus.v[0] * md;
@@ -380,8 +380,8 @@ static void secp256k1_modinv32_var(secp256k1_modinv32_signed30 *x, const secp256
         cond |= gn ^ (gn >> 31);
 
         if (cond == 0) {
-            f.v[len - 2] |= fn << 30;
-            g.v[len - 2] |= gn << 30;
+            f.v[len - 2] |= (uint32_t)fn << 30;
+            g.v[len - 2] |= (uint32_t)gn << 30;
             --len;
         }
     }
diff --git a/src/modinv64.h b/src/modinv64.h
index caff6f5a..6fea9651 100644
--- a/src/modinv64.h
+++ b/src/modinv64.h
@@ -26,7 +26,7 @@ typedef struct {
     secp256k1_modinv64_signed62 modulus;
 
     /* modulus^{-1} mod 2^62 */
-    int64_t modulus_inv62;
+    uint64_t modulus_inv62;
 } secp256k1_modinv64_modinfo;
 
 static void secp256k1_modinv64(secp256k1_modinv64_signed62 *x, const secp256k1_modinv64_modinfo *modinfo);
diff --git a/src/modinv64_impl.h b/src/modinv64_impl.h
index ebf1fe7f..7ce6c909 100644
--- a/src/modinv64_impl.h
+++ b/src/modinv64_impl.h
@@ -177,8 +177,8 @@ static void secp256k1_modinv64_update_de_62(secp256k1_modinv64_signed62 *d, secp
      * the range (-2.P, P), consistent with the input constraint.
...skipping...
index 2cd65557..a15bd2f9 100644
--- a/src/modinv32_impl.h
+++ b/src/modinv32_impl.h
@@ -201,8 +201,8 @@ static void secp256k1_modinv32_update_de_30(secp256k1_modinv32_signed30 *d, secp
      * the range (-2.P, P), consistent with the input constraint.
      */
 
-    md -= (modinfo->modulus_inv30 * (int32_t)cd + md) & M30;
-    me -= (modinfo->modulus_inv30 * (int32_t)ce + me) & M30;
+    md -= (modinfo->modulus_inv30 * (uint32_t)cd + md) & M30;
+    me -= (modinfo->modulus_inv30 * (uint32_t)ce + me) & M30;
 
     /* The modulus has to be odd, so we can assume it is nonzero. */
     cd += (int64_t)modinfo->modulus.v[0] * md;
@@ -380,8 +380,8 @@ static void secp256k1_modinv32_var(secp256k1_modinv32_signed30 *x, const secp256
         cond |= gn ^ (gn >> 31);
 
         if (cond == 0) {
-            f.v[len - 2] |= fn << 30;
-            g.v[len - 2] |= gn << 30;
+            f.v[len - 2] |= (uint32_t)fn << 30;
+            g.v[len - 2] |= (uint32_t)gn << 30;
             --len;
         }
     }
diff --git a/src/modinv64.h b/src/modinv64.h
index caff6f5a..6fea9651 100644
--- a/src/modinv64.h
+++ b/src/modinv64.h
@@ -26,7 +26,7 @@ typedef struct {
     secp256k1_modinv64_signed62 modulus;
 
     /* modulus^{-1} mod 2^62 */
-    int64_t modulus_inv62;
+    uint64_t modulus_inv62;
 } secp256k1_modinv64_modinfo;
 
 static void secp256k1_modinv64(secp256k1_modinv64_signed62 *x, const secp256k1_modinv64_modinfo *modinfo);
diff --git a/src/modinv64_impl.h b/src/modinv64_impl.h
index ebf1fe7f..7ce6c909 100644
--- a/src/modinv64_impl.h
+++ b/src/modinv64_impl.h
@@ -177,8 +177,8 @@ static void secp256k1_modinv64_update_de_62(secp256k1_modinv64_signed62 *d, secp
      * the range (-2.P, P), consistent with the input constraint.
      */
 
-    md -= (modinfo->modulus_inv62 * (int64_t)cd + md) & M62;
-    me -= (modinfo->modulus_inv62 * (int64_t)ce + me) & M62;
+    md -= (modinfo->modulus_inv62 * (uint64_t)cd + md) & M62;
+    me -= (modinfo->modulus_inv62 * (uint64_t)ce + me) & M62;
 
     /* The modulus has to be odd, so we can assume it is nonzero. */
     cd += (int128_t)modinfo->modulus.v[0] * md;
@@ -388,8 +388,8 @@ static void secp256k1_modinv64_var(secp256k1_modinv64_signed62 *x, const secp256
         cond |= gn ^ (gn >> 63);
 
         if (cond == 0) {
-            f.v[len - 2] |= fn << 62;
-            g.v[len - 2] |= gn << 62;
+            f.v[len - 2] |= (uint64_t)fn << 62;
+            g.v[len - 2] |= (uint64_t)gn << 62;
             --len;
         }
     }
sipa

comment created time in 7 hours

pull request commentbitcoin-core/gui

qt: unlock encrypted wallet "OK" button bugfix

This bug was introduced in this commit https://github.com/bitcoin-core/gui/commit/6e950118a31fd6a85026d934fc6adb6255e47e23#diff-6fb84ee9edb2f6effebfefeea02e3548508d2043ea997132a17d9f44505f28d4L223, and it's bc the Decrypt case was removed from the switch statement (which the Unlock case had been falling back to / relying on)

mjdietzx

comment created time in 7 hours

pull request commentbitcoin/bitcoin

rpc: Add min_conf option to fund transaction calls

While looking for this functionability I found this PR, and I also had the same concerns as @gmaxwell regarding the trusted/untrusted. However could we use instead m_min_depth_mine & m_min_depth_theirs similar to

https://github.com/bitcoin/bitcoin/blob/e2ff5e7b35d71195278d2a2ed9485f141de33d7a/src/wallet/coinselection.cpp#L331-L336

and implement it at either AvailableCoins or passing it to coin_selection_params which eventually calls EligibleForSpending. This way we can set 0 || 1 for own transactions, and 3+ for untrusted txs (since node already marks eligible with 1 confirmation, but that's not enough for a third party tx)

I'm interested in submitting a PR in case the proposed resolution is correct.

promag

comment created time in 7 hours

PR closed bitcoin/bitcoin

IGNORE: Testing appveyor build time on Bitcoin Core account

Another test to see how much of an improvement can be made to the appveyor build time by tweaking the build settings and using pre-built dependencies.

+40 -47

0 comment

5 changed files

sipsorcery

pr closed time in 7 hours

Pull request review commentbitcoin/bitcoin

fuzz: Add fuzzing harness for LoadMempool(...) and DumpMempool(...)

+// Copyright (c) 2020 The Bitcoin Core developers+// Distributed under the MIT software license, see the accompanying+// file COPYING or http://www.opensource.org/licenses/mit-license.php.++#include <chainparamsbase.h>+#include <test/fuzz/FuzzedDataProvider.h>+#include <test/fuzz/fuzz.h>+#include <test/fuzz/util.h>+#include <test/util/setup_common.h>+#include <txmempool.h>+#include <validation.h>++#include <cstdint>+#include <vector>++namespace {+FuzzedFileProvider* fuzzed_file_provider_ptr = nullptr;++FILE* fuzzed_fopen(const fs::path&, const char*)+{+    return fuzzed_file_provider_ptr->open();+}+} // namespace++void initialize()+{+    static TestingSetup setup{CBaseChainParams::REGTEST, {"-nodebuglogfile"}};+}++void test_one_input(const std::vector<uint8_t>& buffer)+{+    FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};+    FuzzedFileProvider fuzzed_file_provider = ConsumeFile(fuzzed_data_provider);+    fuzzed_file_provider_ptr = &fuzzed_file_provider;++    CTxMemPool pool;+    (void)LoadMempool(pool, fuzzed_fopen);

Time could be mocked since in LoadMempool there is a call to GetTime.

practicalswift

comment created time in 8 hours

PR opened bitcoin-core/gui

qt: unlock encrypted wallet "OK" button bugfix

When trying to send a transaction from an encrypted wallet, the ask passphrase dialog would not allow the user to click the "OK" button and proceed. Therefore it was impossible to send a transaction through the gui. It was not enabling the "OK" button after the passphrase was entered by the user, because it was using the same form validation logic as the "Change passphrase" flow.

I reported this in a comment in https://github.com/bitcoin-core/gui/issues/136. But then I realized this seems to be a flat out bug. <!-- *** Please remove the following help text before submitting: ***

Pull requests without a rationale and clear improvement may be closed immediately.

GUI-related pull requests should be opened against https://github.com/bitcoin-core/gui first. See CONTRIBUTING.md -->

<!-- Please provide clear motivation for your patch and explain how it improves Bitcoin Core user experience or Bitcoin Core developer experience significantly:

  • Any test improvements or new tests that improve coverage are always welcome.
  • All other changes should have accompanying unit tests (see src/test/) or functional tests (see test/). Contributors should note which tests cover modified code. If no tests exist for a region of modified code, new tests should accompany the change.
  • Bug fixes are most welcome when they come with steps to reproduce or an explanation of the potential issue as well as reasoning for the way the bug was fixed.
  • Features are welcome, but might be rejected due to design or scope issues. If a feature is based on a lot of dependencies, contributors should first consider building the system outside of Bitcoin Core, if possible.
  • Refactoring changes are only accepted if they are required for a feature or bug fix or otherwise improve developer experience significantly. For example, most "code style" refactoring changes require a thorough explanation why they are useful, what downsides they have and why they significantly improve developer experience or avoid serious programming bugs. Note that code style is often a subjective matter. Unless they are explicitly mentioned to be preferred in the developer notes, stylistic code changes are usually rejected. -->

<!-- Bitcoin Core has a thorough review process and even the most trivial change needs to pass a lot of eyes and requires non-zero or even substantial time effort to review. There is a huge lack of active reviewers on the project, so patches often sit for a long time. -->

+2 -0

0 comment

1 changed file

pr created time in 8 hours

pull request commentbitcoin/bitcoin

RPC/Wallet: unloadwallet: Allow specifying wallet_name param matching RPC endpoint wallet

ACK 89bdad5b25ae4ac03a486f729a5b58ae6f21946d

luke-jr

comment created time in 8 hours

pull request commentbitcoin/bitcoin

Well-defined CAddress disk serialization, and addrv2 anchors.dat

Indeed, there is probably no hurry, unless we want to support torv3 anchors in 0.21.

sipa

comment created time in 8 hours

pull request commentbitcoin/bitcoin

Well-defined CAddress disk serialization, and addrv2 anchors.dat

Concept ACK.

From the PR description and quick code reading it follows that there is no hurry to backport these changes into 0.21, right?

sipa

comment created time in 8 hours

PR opened bitcoin/bitcoin

IGNORE: Testing appveyor build time on Bitcoin Core account

Another test to see how much of an improvement can be made to the appveyor build time by tweaking the build settings and using pre-built dependencies.

+40 -47

0 comment

5 changed files

pr created time in 9 hours

pull request commentbitcoin/bitcoin

Well-defined CAddress disk serialization, and addrv2 anchors.dat

I merged the anchors.dat addrv2 support from #20514 into this PR, as doing it correctly requires changes the Cservice serialization from stream version based to stored version based.

sipa

comment created time in 9 hours

PR closed bitcoin/bitcoin

Reviewers
Use addrv2 serialization in anchors.dat Needs backport (0.21)

This changes anchors.dat to use ADDRV2_FORMAT, so its CAddress entries can use v2 serialization.

This solves #20511, but is incompatible with #20509.

This should be compatible with (v1) addresses stored by 0.21.0rc{1,2} as well, as it uses the client version stored in the CAddress records to decide which deserializer to use.

+7 -7

12 comments

1 changed file

sipa

pr closed time in 9 hours

pull request commentbitcoin/bitcoin

Use addrv2 serialization in anchors.dat

If I'm right, then I don't think we necessarily need to fix this for 0.21. We didn't have anchor connections or torv3 before, so the fact that they don't work together isn't a regression and can always be fixed up later

That's fair, and you've shown that this PR as-is actually makes things worse, as it'll fail to deserialize the CService object.

To fix it, we'll either need @vasild's patch from https://github.com/bitcoin/bitcoin/pull/20514#issuecomment-734783860, or doing it on top of #20516. I'm going to close this PR, and take the functionality there.

sipa

comment created time in 9 hours

Pull request review commentbitcoin/bitcoin

[tests] Allow outbound & block-relay-only connections in functional tests.

 static RPCHelpMan addnode()     }; } +static RPCHelpMan addconnection()+{+    return RPCHelpMan{"addconnection",+        "\nOpen an outbound connection to a specified node. This RPC is for testing only.\n",+        {+            {"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The IP address and port to attempt connecting to."},+            {"connectiontype", RPCArg::Type::STR, RPCArg::Optional::NO, "'outbound' or 'blockrelay'."},+        },+        RPCResult{+            RPCResult::Type::OBJ, "", "",+            {+                { RPCResult::Type::STR, "address", "Address of newly added connection." },+                { RPCResult::Type::STR, "connectiontype", "Type of connection opened." },+            }},+        RPCExamples{+            HelpExampleCli("addconnection", "\"192.168.0.6:8333\" \"outbound\"")+            + HelpExampleRpc("addconnection", "\"192.168.0.6:8333\" \"outbound\"")+        },+        [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue+{+    if (!Params().IsMockableChain()) {+        throw std::runtime_error("addconnection is for regression testing (-regtest mode) only.");+    }++    RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VSTR});+    const std::string address = request.params[0].get_str();+    const std::string conn_type_in = request.params[1].get_str();+    ConnectionType conn_type{};+    if (conn_type_in == "outbound") {+        conn_type = ConnectionType::OUTBOUND_FULL_RELAY;+    } else if (conn_type_in == "blockrelay") {+        conn_type = ConnectionType::BLOCK_RELAY;+    } else {+        throw std::runtime_error(self.ToString());+    }++    NodeContext& context = EnsureNodeContext(request.context);+    if (!context.connman) {+        throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled.");+    }++    const bool success = context.connman->AddConnection(address, conn_type);+    if (!success) {+        throw JSONRPCError(RPC_CLIENT_NODE_CAPACITY_REACHED, "Error: Already at capacity for specified connection type.");+    }++    UniValue info(UniValue::VOBJ);+    info.pushKV("address", address);+    info.pushKV("connectiontype", conn_type_in);+

okay, I'm going to resolve this comment. we can revisit once there are specific use cases

amitiuttarwar

comment created time in 10 hours

issue commentbitcoin/bitcoin

Strange state (Timestamps wrong) after importing a priv key.

Nov27-100942

I think I'm hitting this issue? or is this something else? I just did a rescan on latest master as of yesterday and the dates seem wrong at a certain point (after 2017). this is a descriptor wallet.

kollokollo

comment created time in 10 hours

PR opened bitcoin/bitcoin

ci, depends: Do not force Precompiled Headers (PCH) when building Qt

On CentOS 8 (Cirrus CI job) the forced '-pch' option breaks Qt build.

Removing '-pch' option does not affect build time for other systems:

  • master (e2ff5e7b35d71195278d2a2ed9485f141de33d7a):
$ time make -j 9 -C depends/ qt
...
Caching qt...
make: Leaving directory '/home/hebasto/guix/GitHub/bitcoin/depends'

real	4m22,359s
user	18m3,719s
sys     1m24,769s
  • this PR:
$ time make -j 9 -C depends/ qt
...
Caching qt...
make: Leaving directory '/home/hebasto/guix/GitHub/bitcoin/depends'

real	4m14,862s
user	18m3,355s
sys 	1m24,506s

Qt docs: https://doc.qt.io/qt-5/qmake-precompiledheaders.html

Fixes #20423

+1 -3

0 comment

2 changed files

pr created time in 10 hours

pull request commentbitcoin/bitcoin

wallet: introduce setfeerate (an improved settxfee, in sat/vB)

Rebased and updated per the plan outlined in https://github.com/bitcoin/bitcoin/pull/20484#issuecomment-734786305.

jonatack

comment created time in 11 hours

Pull request review commentbitcoin/bitcoin

wallet: upgradewallet fixes, improvements, test coverage

 static RPCHelpMan upgradewallet()         version = request.params[0].get_int();     }     bilingual_str error;-    if (!pwallet->UpgradeWallet(version, error)) {-        throw JSONRPCError(RPC_WALLET_ERROR, error.original);+    const int previous_version{pwallet->GetVersion()};+    const bool wallet_upgraded{pwallet->UpgradeWallet(version, error)};+    const int current_version{pwallet->GetVersion()};+    std::string result;++    if (wallet_upgraded) {+        if (previous_version == current_version) {+            result = "Already at latest version. Wallet version unchanged.";+        } else {+            result = strprintf("Wallet upgraded successfully from version %i to version %i.", previous_version, current_version);+        }     }+     UniValue obj(UniValue::VOBJ);-    if (!error.empty()) {+    obj.pushKV("wallet_name", pwallet->GetName());+    obj.pushKV("previous_version", previous_version);+    obj.pushKV("current_version", current_version);+    if (!result.empty()) {+        obj.pushKV("result", result);+    } else {+        CHECK_NONFATAL(!error.empty());

Done in e915a2a2c87dad5beb68a175b21a07136bcc21ca

jonatack

comment created time in 11 hours

Pull request review commentbitcoin/bitcoin

wallet: upgradewallet fixes, improvements, test coverage

 def dumb_sync_blocks(self):             v16_3_node.submitblock(b)         assert_equal(v16_3_node.getblockcount(), to_height) +    def test_upgradewallet(self, wallet, previous_version, requested_version=None, expected_version=None):

Done in e915a2a2c87dad5beb68a175b21a07136bcc21ca

jonatack

comment created time in 11 hours

Pull request review commentbitcoin/bitcoin

wallet: introduce setfeerate (an improved settxfee, in sat/vB)

 static RPCHelpMan settxfee()     }; } +static RPCHelpMan setfeerate()+{+    return RPCHelpMan{+        "setfeerate",+        "\nSet the transaction fee rate in " + CURRENCY_ATOM + "/vB for this wallet. Overrides the global -paytxfee configuration option.\n"+        "Can be deactivated by passing 0 as the fee rate, in which case automatic fee selection will be used by default.\n",+        {+            {"amount", RPCArg::Type::AMOUNT, RPCArg::Optional::NO, "The transaction fee rate in " + CURRENCY_ATOM + "/vB to set (0 to unset)"},+        },+        RPCResult{+            RPCResult::Type::OBJ, "", "",+            {+                {RPCResult::Type::STR, "wallet_name", "Name of the wallet the fee rate setting applies to"},+                {RPCResult::Type::NUM, "fee_rate", "Fee rate after this operation"},+                {RPCResult::Type::STR, "result", /* optional */ true, "Description of result, if successful"},+                {RPCResult::Type::STR, "error", /* optional */ true, "Description of error, if any"},+            },+        },+        RPCExamples{+            ""+            "\nSet a fee rate of 1 " + CURRENCY_ATOM + "/vB\n"+            + HelpExampleCli("setfeerate", "1") ++            "\nSet a fee rate of 3.141 " + CURRENCY_ATOM + "/vB\n"+            + HelpExampleCli("setfeerate", "3.141") ++            "\nSet a fee rate of 7.75 " + CURRENCY_ATOM + "/vB with named arguments\n"+            + HelpExampleCli("-named setfeerate", "amount=7.75") ++            "\nSet a fee rate of 25 " + CURRENCY_ATOM + "/vB with the RPC\n"+            + HelpExampleRpc("setfeerate", "25")+        },+        [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue {+            std::shared_ptr<CWallet> const rpc_wallet{GetWalletForJSONRPCRequest(request)};+            if (!rpc_wallet) return NullUniValue;+            CWallet& wallet = *rpc_wallet;++            LOCK(wallet.cs_wallet);++            CFeeRate amount{AmountFromValue(request.params[0]), COIN};+            std::string amount_str{amount.ToString(FeeEstimateMode::SAT_B)};+            std::string current_amount_str{wallet.m_pay_tx_fee.ToString(FeeEstimateMode::SAT_B)};+            CFeeRate relay_min_feerate(wallet.chain().relayMinFee().GetFeePerK());+            CFeeRate wallet_min_feerate(wallet.m_min_fee.GetFeePerK());+            CFeeRate wallet_max_feerate(wallet.m_default_max_tx_fee, 1000);+            std::string result, error;++            if (amount == CFeeRate(0)) {+                wallet.m_pay_tx_fee = amount;+                result = "Fee rate for transactions with this wallet successfully unset. By default, automatic fee selection will be used.";+            } else if (amount < relay_min_feerate) {+                error = strprintf("The requested fee rate of %s cannot be less than the minimum relay fee rate of %s. The current setting of %s for this wallet remains unchanged.", amount_str, relay_min_feerate.ToString(FeeEstimateMode::SAT_B), current_amount_str);+            } else if (amount < wallet_min_feerate) {+                error = strprintf("The requested fee rate of %s cannot be less than the wallet min fee rate of %s. The current setting of %s for this wallet remains unchanged.", amount_str, wallet_min_feerate.ToString(FeeEstimateMode::SAT_B), current_amount_str);+            } else if (amount > wallet_max_feerate) {+                error = strprintf("The requested fee rate of %s cannot be greater than the wallet max fee rate of %s. The current setting of %s for this wallet remains unchanged.", amount_str, wallet_max_feerate.ToString(FeeEstimateMode::SAT_B), current_amount_str);+            } else {+                wallet.m_pay_tx_fee = amount;+                result = "Fee rate for transactions with this wallet successfully set to " + amount_str;+            }++            UniValue obj(UniValue::VOBJ);+            obj.pushKV("wallet_name", wallet.GetName());+            obj.pushKV("fee_rate", UniValue(UniValue::VNUM, wallet.m_pay_tx_fee.SatsToString()));

Maybe rebase this on top of 8798383

Pulled 8798383 in as commit 0e2c3ace86b8aa

jonatack

comment created time in 11 hours

more