Refactor importing BTC addresses into son-wallet #325

Closed
opened 2022-03-17 22:16:49 +00:00 by serkixenos · 16 comments
serkixenos commented 2022-03-17 22:16:49 +00:00 (Migrated from gitlab.com)

Currently, we use importaddress RPC call to import primary wallet and deposit addresses into BTC wallet used by SONs.

Due to chain rescan that executes on address import, wallet is unavailable for some time, and only very few addresses are actually imported. This prevents SONs to track and query transactions.

Importing primary wallet and deposit addresses should be refactored to use importmulti RPC, to import all addresses in one go, and limit rescaning time from HARDFORK_SON_TIME only.

Currently, we use importaddress RPC call to import primary wallet and deposit addresses into BTC wallet used by SONs. Due to chain rescan that executes on address import, wallet is unavailable for some time, and only very few addresses are actually imported. This prevents SONs to track and query transactions. Importing primary wallet and deposit addresses should be refactored to use importmulti RPC, to import all addresses in one go, and limit rescaning time from HARDFORK_SON_TIME only.
vampik commented 2022-03-18 15:55:33 +00:00 (Migrated from gitlab.com)

assigned to @vampik

assigned to @vampik
serkixenos commented 2022-03-18 17:11:08 +00:00 (Migrated from gitlab.com)

mentioned in issue #312

mentioned in issue #312
vampik commented 2022-03-18 18:31:43 +00:00 (Migrated from gitlab.com)

mentioned in commit 73e9ebb055

mentioned in commit 73e9ebb0550848b7248be2ee936617e54c891fe5
bobinson commented 2022-03-18 18:45:51 +00:00 (Migrated from gitlab.com)

limit rescaning time from HARDFORK_SON_TIME only.

Why not from a recent HF time ? We had no other transactions happened before and can avoid scanning months worth transactions ?

> limit rescaning time from HARDFORK_SON_TIME only. Why not from a recent HF time ? We had no other transactions happened before and can avoid scanning months worth transactions ?
vampik commented 2022-03-18 21:01:51 +00:00 (Migrated from gitlab.com)

mentioned in commit 9132908283

mentioned in commit 9132908283ca97b0017ae68447da250453f85c81
vampik commented 2022-03-21 12:23:46 +00:00 (Migrated from gitlab.com)

created branch 325-refactor-importing-btc-addresses-into-son-wallet to address this issue

created branch [`325-refactor-importing-btc-addresses-into-son-wallet`](/PBSA/peerplays/-/compare/master...325-refactor-importing-btc-addresses-into-son-wallet) to address this issue
vampik commented 2022-03-21 12:25:28 +00:00 (Migrated from gitlab.com)

mentioned in merge request !87

mentioned in merge request !87
vampik commented 2022-03-21 13:17:28 +00:00 (Migrated from gitlab.com)

mentioned in merge request !88

mentioned in merge request !88
vampik commented 2022-03-21 14:50:03 +00:00 (Migrated from gitlab.com)

mentioned in commit ee018cf513

mentioned in commit ee018cf513b707e1f05860c477b0c1fa7c4b0b17
serkixenos commented 2022-03-21 14:50:03 +00:00 (Migrated from gitlab.com)

mentioned in commit a408ed0dda

mentioned in commit a408ed0dda9a4f4259aa7db86f4800bca9678af4
serkixenos commented 2022-03-21 15:24:30 +00:00 (Migrated from gitlab.com)

Good point, we'll change it to a more recent timestamp.

Good point, we'll change it to a more recent timestamp.
serkixenos commented 2022-03-23 13:04:34 +00:00 (Migrated from gitlab.com)

Wallet rescan limited from 2022-01-01

Wallet rescan limited from 2022-01-01
serkixenos commented 2022-03-23 13:04:49 +00:00 (Migrated from gitlab.com)

assigned to @prandnum

assigned to @prandnum
vampik commented 2022-03-30 08:23:35 +00:00 (Migrated from gitlab.com)

Steps to test:

FROM bitcoin:

./init-network.sh

Unlock the wallet

./bitcoin-cli -rpcuser=1 -rpcpassword=1 -rpcwallet=son-wallet walletpassphrase 9da115c9fa6fe7fd09390841ac91aee4 600

Get bitcoin test address:

./bitcoin-cli -rpcuser=1 -rpcpassword=1 -rpcwallet=son-wallet getaddressinfo bcrt1qrdla409frurxgla7gazpqe89lh00n7ht0n2l2tq82g70hahkw3gs0c4v0q
{
  "address": "bcrt1qrdla409frurxgla7gazpqe89lh00n7ht0n2l2tq82g70hahkw3gs0c4v0q",
  "scriptPubKey": "00201b7fdabca91f06647fbe47441064e5fddef9faeb7cd5f52c07523cfbf6f67451",
  "ismine": false,
  "solvable": false,
  "iswatchonly": false,
  "isscript": true,
  "iswitness": true,
  "witness_version": 0,
  "witness_program": "1b7fdabca91f06647fbe47441064e5fddef9faeb7cd5f52c07523cfbf6f67451",
  "ischange": false,
  "labels": [
  ]
}

From the witness_node:

Start witness_node

./init-network.sh

Wait for maintenance block

Check in bitcoin that timestamp for address appears (or changed if there was already timestamp)

./bitcoin-cli -rpcuser=1 -rpcpassword=1 -rpcwallet=son-wallet getaddressinfo bcrt1qrdla409frurxgla7gazpqe89lh00n7ht0n2l2tq82g70hahkw3gs0c4v0q
{
  "address": "bcrt1qrdla409frurxgla7gazpqe89lh00n7ht0n2l2tq82g70hahkw3gs0c4v0q",
  "scriptPubKey": "00201b7fdabca91f06647fbe47441064e5fddef9faeb7cd5f52c07523cfbf6f67451",
  "ismine": false,
  "solvable": false,
  "iswatchonly": true,
  "isscript": true,
  "iswitness": true,
  "witness_version": 0,
  "witness_program": "1b7fdabca91f06647fbe47441064e5fddef9faeb7cd5f52c07523cfbf6f67451",
  "ischange": false,
  "timestamp": 1640995200,
  "labels": [
    ""
  ]
}
Steps to test: FROM bitcoin: `./init-network.sh` Unlock the wallet `./bitcoin-cli -rpcuser=1 -rpcpassword=1 -rpcwallet=son-wallet walletpassphrase 9da115c9fa6fe7fd09390841ac91aee4 600` Get bitcoin test address: ``` ./bitcoin-cli -rpcuser=1 -rpcpassword=1 -rpcwallet=son-wallet getaddressinfo bcrt1qrdla409frurxgla7gazpqe89lh00n7ht0n2l2tq82g70hahkw3gs0c4v0q { "address": "bcrt1qrdla409frurxgla7gazpqe89lh00n7ht0n2l2tq82g70hahkw3gs0c4v0q", "scriptPubKey": "00201b7fdabca91f06647fbe47441064e5fddef9faeb7cd5f52c07523cfbf6f67451", "ismine": false, "solvable": false, "iswatchonly": false, "isscript": true, "iswitness": true, "witness_version": 0, "witness_program": "1b7fdabca91f06647fbe47441064e5fddef9faeb7cd5f52c07523cfbf6f67451", "ischange": false, "labels": [ ] } ``` From the witness_node: Start `witness_node` `./init-network.sh` Wait for maintenance block Check in bitcoin that timestamp for address appears (or changed if there was already timestamp) ``` ./bitcoin-cli -rpcuser=1 -rpcpassword=1 -rpcwallet=son-wallet getaddressinfo bcrt1qrdla409frurxgla7gazpqe89lh00n7ht0n2l2tq82g70hahkw3gs0c4v0q { "address": "bcrt1qrdla409frurxgla7gazpqe89lh00n7ht0n2l2tq82g70hahkw3gs0c4v0q", "scriptPubKey": "00201b7fdabca91f06647fbe47441064e5fddef9faeb7cd5f52c07523cfbf6f67451", "ismine": false, "solvable": false, "iswatchonly": true, "isscript": true, "iswitness": true, "witness_version": 0, "witness_program": "1b7fdabca91f06647fbe47441064e5fddef9faeb7cd5f52c07523cfbf6f67451", "ischange": false, "timestamp": 1640995200, "labels": [ "" ] } ```
prandnum commented 2022-03-30 17:53:28 +00:00 (Migrated from gitlab.com)
root@020d26dae26b:~/bitcoin-network# ./bitcoin-cli -rpcuser=1 -rpcpassword=1 -rpcwallet=son-wallet getaddressinfo bcrt1qrdla409frurxgla7gazpqe89lh00n7ht0n2l2tq82g70ha                                                                       hkw3gs0c4v0q
{
  "address": "bcrt1qrdla409frurxgla7gazpqe89lh00n7ht0n2l2tq82g70hahkw3gs0c4v0q",
  "scriptPubKey": "00201b7fdabca91f06647fbe47441064e5fddef9faeb7cd5f52c07523cfbf6f67451",
  "ismine": false,
  "solvable": false,
  "iswatchonly": false,
  "isscript": true,
  "iswitness": true,
  "witness_version": 0,
  "witness_program": "1b7fdabca91f06647fbe47441064e5fddef9faeb7cd5f52c07523cfbf6f67451",
  "ischange": false,
  "labels": [
  ]
}
root@020d26dae26b:~/bitcoin-network# ./bitcoin-cli -rpcuser=1 -rpcpassword=1 -rpcwallet=son-wallet getaddressinfo bcrt1qrdla409frurxgla7gazpqe89lh00n7ht0n2l2tq82g70ha                                                                       hkw3gs0c4v0q
{
  "address": "bcrt1qrdla409frurxgla7gazpqe89lh00n7ht0n2l2tq82g70hahkw3gs0c4v0q",
  "scriptPubKey": "00201b7fdabca91f06647fbe47441064e5fddef9faeb7cd5f52c07523cfbf6f67451",
  "ismine": false,
  "solvable": false,
  "iswatchonly": true,
  "isscript": true,
  "iswitness": true,
  "witness_version": 0,
  "witness_program": "1b7fdabca91f06647fbe47441064e5fddef9faeb7cd5f52c07523cfbf6f67451",
  "ischange": false,
  "timestamp": 1640995200,
  "labels": [
    ""
  ]
}
root@020d26dae26b:~/bitcoin-network#
``` root@020d26dae26b:~/bitcoin-network# ./bitcoin-cli -rpcuser=1 -rpcpassword=1 -rpcwallet=son-wallet getaddressinfo bcrt1qrdla409frurxgla7gazpqe89lh00n7ht0n2l2tq82g70ha hkw3gs0c4v0q { "address": "bcrt1qrdla409frurxgla7gazpqe89lh00n7ht0n2l2tq82g70hahkw3gs0c4v0q", "scriptPubKey": "00201b7fdabca91f06647fbe47441064e5fddef9faeb7cd5f52c07523cfbf6f67451", "ismine": false, "solvable": false, "iswatchonly": false, "isscript": true, "iswitness": true, "witness_version": 0, "witness_program": "1b7fdabca91f06647fbe47441064e5fddef9faeb7cd5f52c07523cfbf6f67451", "ischange": false, "labels": [ ] } root@020d26dae26b:~/bitcoin-network# ./bitcoin-cli -rpcuser=1 -rpcpassword=1 -rpcwallet=son-wallet getaddressinfo bcrt1qrdla409frurxgla7gazpqe89lh00n7ht0n2l2tq82g70ha hkw3gs0c4v0q { "address": "bcrt1qrdla409frurxgla7gazpqe89lh00n7ht0n2l2tq82g70hahkw3gs0c4v0q", "scriptPubKey": "00201b7fdabca91f06647fbe47441064e5fddef9faeb7cd5f52c07523cfbf6f67451", "ismine": false, "solvable": false, "iswatchonly": true, "isscript": true, "iswitness": true, "witness_version": 0, "witness_program": "1b7fdabca91f06647fbe47441064e5fddef9faeb7cd5f52c07523cfbf6f67451", "ischange": false, "timestamp": 1640995200, "labels": [ "" ] } root@020d26dae26b:~/bitcoin-network# ```
prandnum (Migrated from gitlab.com) closed this issue 2022-03-30 17:53:28 +00:00
vampik commented 2022-03-31 19:09:51 +00:00 (Migrated from gitlab.com)

mentioned in issue #337

mentioned in issue #337
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Peerplays_Blockchain/peerplays_migrated#325
No description provided.