mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-20 13:37:28 +02:00
Merge ac92ab6da5 into merged_master (Bitcoin PR bitcoin/bitcoin#23113)
This commit is contained in:
commit
86f68b94d0
4 changed files with 44 additions and 6 deletions
9
doc/release-notes-23113.md
Normal file
9
doc/release-notes-23113.md
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
Notable changes
|
||||
===============
|
||||
|
||||
Updated RPCs
|
||||
------------
|
||||
|
||||
- Both `createmultisig` and `addmultisigaddress` now include a `warnings`
|
||||
field, which will show a warning if a non-legacy address type is requested
|
||||
when using uncompressed public keys.
|
||||
|
|
@ -150,6 +150,10 @@ static RPCHelpMan createmultisig()
|
|||
{RPCResult::Type::STR, "address", "The value of the new multisig address."},
|
||||
{RPCResult::Type::STR_HEX, "redeemScript", "The string value of the hex-encoded redemption script."},
|
||||
{RPCResult::Type::STR, "descriptor", "The descriptor for this multisig"},
|
||||
{RPCResult::Type::ARR, "warnings", /* optional */ true, "Any warnings resulting from the creation of this multisig",
|
||||
{
|
||||
{RPCResult::Type::STR, "", ""},
|
||||
}},
|
||||
}
|
||||
},
|
||||
RPCExamples{
|
||||
|
|
@ -198,6 +202,13 @@ static RPCHelpMan createmultisig()
|
|||
result.pushKV("redeemScript", HexStr(inner));
|
||||
result.pushKV("descriptor", descriptor->ToString());
|
||||
|
||||
UniValue warnings(UniValue::VARR);
|
||||
if (!request.params[2].isNull() && OutputTypeFromDestination(dest) != output_type) {
|
||||
// Only warns if the user has explicitly chosen an address type we cannot generate
|
||||
warnings.push_back("Unable to make chosen address type, please ensure no uncompressed public keys are present.");
|
||||
}
|
||||
if (warnings.size()) result.pushKV("warnings", warnings);
|
||||
|
||||
return result;
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -252,7 +252,11 @@ RPCHelpMan addmultisigaddress()
|
|||
{RPCResult::Type::STR, "address", "The value of the new multisig address"},
|
||||
{RPCResult::Type::STR_HEX, "redeemScript", "The string value of the hex-encoded redemption script"},
|
||||
{RPCResult::Type::STR, "descriptor", "The descriptor for this multisig"},
|
||||
},
|
||||
{RPCResult::Type::ARR, "warnings", /* optional */ true, "Any warnings resulting from the creation of this multisig",
|
||||
{
|
||||
{RPCResult::Type::STR, "", ""},
|
||||
}},
|
||||
}
|
||||
},
|
||||
RPCExamples{
|
||||
"\nAdd a multisig address from 2 addresses\n"
|
||||
|
|
@ -309,6 +313,14 @@ RPCHelpMan addmultisigaddress()
|
|||
result.pushKV("address", EncodeDestination(dest));
|
||||
result.pushKV("redeemScript", HexStr(inner));
|
||||
result.pushKV("descriptor", descriptor->ToString());
|
||||
|
||||
UniValue warnings(UniValue::VARR);
|
||||
if (!request.params[3].isNull() && OutputTypeFromDestination(dest) != output_type) {
|
||||
// Only warns if the user has explicitly chosen an address type we cannot generate
|
||||
warnings.push_back("Unable to make chosen address type, please ensure no uncompressed public keys are present.");
|
||||
}
|
||||
if (warnings.size()) result.pushKV("warnings", warnings);
|
||||
|
||||
return result;
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -75,13 +75,19 @@ class RpcCreateMultiSigTest(BitcoinTestFramework):
|
|||
for keys in itertools.permutations([pk0, pk1, pk2]):
|
||||
# Results should be the same as this legacy one
|
||||
legacy_addr = node0.createmultisig(2, keys, 'legacy')['address']
|
||||
assert_equal(legacy_addr, wmulti0.addmultisigaddress(2, keys, '', 'legacy')['address'])
|
||||
result = wmulti0.addmultisigaddress(2, keys, '', 'legacy')
|
||||
assert_equal(legacy_addr, result['address'])
|
||||
assert 'warnings' not in result
|
||||
|
||||
# Generate addresses with the segwit types. These should all make legacy addresses
|
||||
assert_equal(legacy_addr, wmulti0.createmultisig(2, keys, 'bech32')['address'])
|
||||
assert_equal(legacy_addr, wmulti0.createmultisig(2, keys, 'p2sh-segwit')['address'])
|
||||
assert_equal(legacy_addr, wmulti0.addmultisigaddress(2, keys, '', 'bech32')['address'])
|
||||
assert_equal(legacy_addr, wmulti0.addmultisigaddress(2, keys, '', 'p2sh-segwit')['address'])
|
||||
for addr_type in ['bech32', 'p2sh-segwit']:
|
||||
result = wmulti0.createmultisig(2, keys, addr_type)
|
||||
assert_equal(legacy_addr, result['address'])
|
||||
assert_equal(result['warnings'], ["Unable to make chosen address type, please ensure no uncompressed public keys are present."])
|
||||
|
||||
result = wmulti0.addmultisigaddress(2, keys, '', addr_type)
|
||||
assert_equal(legacy_addr, result['address'])
|
||||
assert_equal(result['warnings'], ["Unable to make chosen address type, please ensure no uncompressed public keys are present."])
|
||||
|
||||
self.log.info('Testing sortedmulti descriptors with BIP 67 test vectors')
|
||||
with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data/rpc_bip67.json'), encoding='utf-8') as f:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue