Qortal / qortal

Qortal Project Core - decentralize the world - Data storage, communications, web hosting, decentralized trading, complete infrastructure for the future blockchain based Internet
https://qortal.org
70 stars 59 forks source link

P2SH-A is refunded to a different BTC address #19

Closed archived-2 closed 4 years ago

archived-2 commented 4 years ago

One trade has reached the ALICE_REFUNDED stage, and I was expecting to see the BTC returned to my wallet. Instead, it has been sent to a wallet address that I don't recognise.

My BTC wallet address: 16wjb7k8cRBY5UAzfTSJ7iKtqeUL71SrzQ BTC was instead refunded to: 15LHP77t8JpRnAMBiBpiGrBKWeLZcCAwEM

Here's a link to the P2SH-A transaction. You can see the funds haven't been returned to the same address they were originally sent from: https://www.blockchain.com/btc/address/36WvpRf6uvZZjzQ3CfK7tyhkcnMBdgPAhj

I had a look at the code and it appears as though BTC is refunded to refundKey.getPubKeyHash(), which is derived from tradeBotData.getTradePrivateKey(). Right now there is no obvious way for me to access this BTC. Do I need to sign a transaction manually?

catbref commented 4 years ago

Yes, it looks like the address 15LHP77t8JpRnAMBiBpiGrBKWeLZcCAwEM has been derived from the "trade private key". You should be able to find this in your "trade-bot entries" via API call GET /crosschain/tradebot Convert the trade private key from base58 to Bitcoin WIF and import into wallet software to recover your funds.

The fix needed should scan your wallet for an unused receive address and refund back to that instead.

archived-2 commented 4 years ago

Thank you. I will try that and will report back. The part I was missing was the conversion from base58 to Bitcoin WIF.

catbref commented 4 years ago

This page might help: Bitcoin Wallet import format (DO add the 0x01 for compressed public key)

You'll know if you converted the "tradePrivateKey" correctly as your wallet software will show a balance for 15LHP77t8JpRnAMBiBpiGrBKWeLZcCAwEM

lotw7277 commented 4 years ago

@tcallahan14 Were you able to derive the WIF from the private key or you still need more help on that ?

archived-2 commented 4 years ago

Thanks @lotw7277 and @catbref. I will try the conversion tomorrow - but it shouldn't be a problem.

Once that's done I might see if I can submit a fix.

catbref commented 4 years ago

I've already coded a fix that will pick the first unused 'receive' address from your wallet. Should make it into v1.3.4!

archived-2 commented 4 years ago

Ah nice - that was quick. I'll check it out :)