From 9a2377cd5de4d716c40cbafb7fe86f673d7f0f93 Mon Sep 17 00:00:00 2001 From: psolstice Date: Sun, 17 Dec 2023 18:26:45 +0100 Subject: [PATCH] Fixes for exchange address implementation (#1375) * Fixed wallet address book for exchange addresses * Fixed testnet exchange address prefix * Change error text --- src/chainparams.cpp | 2 +- src/spark/sparkwallet.cpp | 2 +- src/wallet/lelantusjoinsplitbuilder.cpp | 2 +- src/wallet/rpcwallet.cpp | 2 ++ 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 589d2f199f..55a6323049 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -664,7 +664,7 @@ class CTestNetParams : public CChainParams { base58Prefixes[PUBKEY_ADDRESS] = std::vector < unsigned char > (1, 65); base58Prefixes[SCRIPT_ADDRESS] = std::vector < unsigned char > (1, 178); - base58Prefixes[EXCHANGE_PUBKEY_ADDRESS] = {0x01, 0xb9, 0xbb}; // EXT prefix for the address + base58Prefixes[EXCHANGE_PUBKEY_ADDRESS] = {0x01, 0xb9, 0xb1}; // EXT prefix for the address base58Prefixes[SECRET_KEY] = std::vector < unsigned char > (1, 185); base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x35)(0x87)(0xCF).convert_to_container < std::vector < unsigned char > > (); base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x35)(0x83)(0x94).convert_to_container < std::vector < unsigned char > > (); diff --git a/src/spark/sparkwallet.cpp b/src/spark/sparkwallet.cpp index a6199008b7..69502c8c18 100644 --- a/src/spark/sparkwallet.cpp +++ b/src/spark/sparkwallet.cpp @@ -1231,7 +1231,7 @@ CWalletTx CSparkWallet::CreateSparkSpendTransaction( auto& recipient = recipients[i]; if (recipient.scriptPubKey.IsPayToExchangeAddress()) { - throw std::runtime_error("Cannot create private transaction with exchange address as a destination"); + throw std::runtime_error("Exchange addresses cannot receive private funds. Please transfer your funds to a transparent address first before sending to an Exchange address"); } if (!MoneyRange(recipient.nAmount)) { diff --git a/src/wallet/lelantusjoinsplitbuilder.cpp b/src/wallet/lelantusjoinsplitbuilder.cpp index b294bd3900..a10eb4483f 100644 --- a/src/wallet/lelantusjoinsplitbuilder.cpp +++ b/src/wallet/lelantusjoinsplitbuilder.cpp @@ -60,7 +60,7 @@ CWalletTx LelantusJoinSplitBuilder::Build( auto& recipient = recipients[i]; if (recipient.scriptPubKey.IsPayToExchangeAddress()) { - throw std::runtime_error("Cannot create private transaction with exchange address as a destination"); + throw std::runtime_error("Exchange addresses cannot receive private funds. Please transfer your funds to a transparent address first before sending to an Exchange address"); } if (!MoneyRange(recipient.nAmount)) { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 61564146fe..0f83a5641a 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -260,6 +260,8 @@ UniValue getnewexchangeaddress(const JSONRPCRequest& request) CBitcoinAddress newAddress; newAddress.SetExchange(keyID); + pwallet->SetAddressBook(newAddress.Get(), "", "receive"); + return newAddress.ToString(); }