mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-12 14:21:20 +02:00
gui: change example address from legacy (P2PKH) to bech32m (P2TR)
The dummy addresses have been computed with the following Python script (executed under ./test/functional): -------------------------------------------------------------------------------------------------------- from test_framework.segwit_addr import CHARSET, decode_segwit_address, encode_segwit_address from test_framework.messages import sha256 output_key = sha256(b'bitcoin dummy taproot output key') for network, hrp in [('mainnet', 'bc'), ('signet', 'tb'), ('testnet', 'tb'), ('regtest', 'bcrt')]: dummy_address = encode_segwit_address(hrp, 1, output_key) while decode_segwit_address(hrp, dummy_address) != (None, None): last_char = CHARSET[(CHARSET.index(dummy_address[-1]) + 1) % 32] dummy_address = dummy_address[:-1] + last_char print(f'{network:7} example address: {dummy_address}') -------------------------------------------------------------------------------------------------------- Co-authored-by: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>
This commit is contained in:
parent
bf1b6383db
commit
c6d1b8de89
@ -109,22 +109,26 @@ QFont fixedPitchFont(bool use_embedded_font)
|
||||
return QFontDatabase::systemFont(QFontDatabase::FixedFont);
|
||||
}
|
||||
|
||||
// Just some dummy data to generate a convincing random-looking (but consistent) address
|
||||
static const uint8_t dummydata[] = {0xeb,0x15,0x23,0x1d,0xfc,0xeb,0x60,0x92,0x58,0x86,0xb6,0x7d,0x06,0x52,0x99,0x92,0x59,0x15,0xae,0xb1,0x72,0xc0,0x66,0x47};
|
||||
|
||||
// Generate a dummy address with invalid CRC, starting with the network prefix.
|
||||
// Return a pre-generated dummy bech32m address (P2TR) with invalid checksum.
|
||||
static std::string DummyAddress(const CChainParams ¶ms)
|
||||
{
|
||||
std::vector<unsigned char> sourcedata = params.Base58Prefix(CChainParams::PUBKEY_ADDRESS);
|
||||
sourcedata.insert(sourcedata.end(), dummydata, dummydata + sizeof(dummydata));
|
||||
for(int i=0; i<256; ++i) { // Try every trailing byte
|
||||
std::string s = EncodeBase58(sourcedata);
|
||||
if (!IsValidDestinationString(s)) {
|
||||
return s;
|
||||
}
|
||||
sourcedata[sourcedata.size()-1] += 1;
|
||||
}
|
||||
return "";
|
||||
std::string addr;
|
||||
switch (params.GetChainType()) {
|
||||
case ChainType::MAIN:
|
||||
addr = "bc1p35yvjel7srp783ztf8v6jdra7dhfzk5jaun8xz2qp6ws7z80n4tq2jku9f";
|
||||
break;
|
||||
case ChainType::SIGNET:
|
||||
case ChainType::TESTNET:
|
||||
addr = "tb1p35yvjel7srp783ztf8v6jdra7dhfzk5jaun8xz2qp6ws7z80n4tqa6qnlg";
|
||||
break;
|
||||
case ChainType::REGTEST:
|
||||
addr = "bcrt1p35yvjel7srp783ztf8v6jdra7dhfzk5jaun8xz2qp6ws7z80n4tqsr2427";
|
||||
break;
|
||||
} // no default case, so the compiler can warn about missing cases
|
||||
assert(!addr.empty());
|
||||
|
||||
if (Assume(!IsValidDestinationString(addr))) return addr;
|
||||
return {};
|
||||
}
|
||||
|
||||
void setupAddressWidget(QValidatedLineEdit *widget, QWidget *parent)
|
||||
|
Loading…
x
Reference in New Issue
Block a user