2020-10-30 14:45:38 +03:00
|
|
|
# btc-wallet-* Scratch Code
|
|
|
|
|
|
|
|
## xpub
|
2020-11-17 18:34:48 +03:00
|
|
|
xpub1 is from mnemonic from PRIVATE.scratch
|
2020-10-30 14:45:38 +03:00
|
|
|
```
|
2020-12-10 16:22:48 +03:00
|
|
|
=bl -build-file %/lib/btc-wallet-store/hoon
|
2020-10-31 12:41:00 +03:00
|
|
|
=xpub1 'zpub6r8dKyWJ31XF6n69KKeEwLjVC5ruqAbiJ4QCqLsrV36Mvx9WEjUaiPNPGFLHNCCqgCdy6iZC8ZgHsm6a1AUTVBMVbKGemNcWFcwBGSjJKbD'
|
|
|
|
=xpub2 'xpub6D7yaZieZEeG617UcKXDhbsDeso6bmxSAiGWkvkASoiwcjaRtrH5HeNRnDT25s7zmxYzj6MtFe32dVqcf9YcBKKgn9THHjwn2uSjkvobK4e'
|
2020-10-30 14:45:38 +03:00
|
|
|
=bl -build-file %/lib/btc-wallet-store/hoon
|
|
|
|
```
|
|
|
|
|
|
|
|
### get address at indices
|
|
|
|
```
|
2020-12-08 20:51:14 +03:00
|
|
|
=walt1 (from-xpub:bl xpub1 [%4 0x5566.7788] ~ ~ ~)
|
2020-11-11 15:30:22 +03:00
|
|
|
(~(mk-address wad:bl walt1 %0) 0)
|
|
|
|
:: gives [%bech32 'bc1q0adfj7ur750hjwufzzlfj5ytqzsnd7fz9fjuzc']
|
2020-10-30 14:45:38 +03:00
|
|
|
```
|
|
|
|
|
2020-10-31 12:41:00 +03:00
|
|
|
### update address data
|
|
|
|
```
|
2020-12-08 20:51:14 +03:00
|
|
|
=walt1 (from-xpub:bl xpub1 ~ ~ ~)
|
2020-11-11 15:30:22 +03:00
|
|
|
(~(mk-address wad:bl walt1 %0) 0)
|
2020-10-31 14:25:32 +03:00
|
|
|
:: gives bc1q0adfj7ur750hjwufzzlfj5ytqzsnd7fz9fjuzc
|
2020-11-11 15:30:22 +03:00
|
|
|
=walt1 (~(watch-address wad:bl walt1 %0) [%bech32 'bc1q0adfj7ur750hjwufzzlfj5ytqzsnd7fz9fjuzc'] [%0 0 ~])
|
|
|
|
nixt.walt1
|
2020-10-31 14:25:32 +03:00
|
|
|
:: gives [p=1 q=0] (nixt updated since it was 0)
|
2020-11-11 15:30:22 +03:00
|
|
|
=walt1 (~(watch-address wad:bl walt1 %0) [%bech32 'bc1qa5jcdww8u8493zttjjf6q5wu89e6knpvmsh7x4'] [%0 2 ~])
|
|
|
|
nixt.walt1=walt1 (~(watch-address wad:bl walt1 %0) [%bech32 'bc1qa5jcdww8u8493zttjjf6q5wu89e6knpvmsh7x4'] [%0 2 ~])
|
|
|
|
nixt.walt1
|
2020-10-31 14:25:32 +03:00
|
|
|
:: gives [p=1 q=0] (no update)
|
2020-11-11 15:30:22 +03:00
|
|
|
=walt1 (~(watch-address wad:bl walt1 %0) [%bech32 'bc1qvqrdh8suyv63ntaa0d7hmcamavv8283sngh6e5'] [%0 1 ~])
|
|
|
|
nixt.walt1
|
2020-10-31 14:25:32 +03:00
|
|
|
:: gives [p=3 q=0] (skips index 2, since already a used address there)
|
2020-11-02 10:21:48 +03:00
|
|
|
|
2020-11-11 15:30:22 +03:00
|
|
|
=walt1 (~(watch-address wad:bl walt1 %0) [%bech32 'bc1qvqrdh8suyv63ntaa0d7hmcamavv8283sngh6e5'] [%0 4 ~])
|
|
|
|
:: gives error, because address is inserted at index that doesn't match it
|
2020-11-02 10:21:48 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
### generate new address (for receiving payment)
|
|
|
|
```
|
2020-11-11 16:54:47 +03:00
|
|
|
=walt1 (from-xpub:bl xpub1 ~ ~)
|
|
|
|
=res ~(gen-address wad:bl walt1 %0)
|
2020-11-02 10:21:48 +03:00
|
|
|
p.res
|
2020-11-11 16:54:47 +03:00
|
|
|
nixt.q.res
|
2020-11-02 10:21:48 +03:00
|
|
|
:: gives
|
|
|
|
:: [%bech32 'bc1q0adfj7ur750hjwufzzlfj5ytqzsnd7fz9fjuzc']
|
|
|
|
:: [p=1 q=0]
|
2020-10-31 12:41:00 +03:00
|
|
|
```
|
|
|
|
|
2020-11-02 20:51:19 +03:00
|
|
|
## Scanning
|
2020-11-03 14:50:10 +03:00
|
|
|
Mnemonic
|
|
|
|
```
|
|
|
|
abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about
|
|
|
|
```
|
2020-11-02 20:51:19 +03:00
|
|
|
|
2020-12-09 12:35:02 +03:00
|
|
|
### DEPRECATED manual scanning of empty wallet
|
|
|
|
SEE Address Generation instead
|
2020-11-11 16:54:47 +03:00
|
|
|
Uses `btc-wallet-hook`, with max-gap=3
|
2020-11-02 20:51:19 +03:00
|
|
|
```
|
2020-11-13 15:47:11 +03:00
|
|
|
:btc-provider|command [%set-credentials api-url='http://localhost:50002']
|
2020-12-04 21:54:59 +03:00
|
|
|
:btc-wallet-hook|action [%set-provider ~zod]
|
2020-11-02 20:51:19 +03:00
|
|
|
=scan-xpub 'zpub6rFR7y4Q2AijBEqTUquhVz398htDFrtymD9xYYfG1m4wAcvPhXNfE3EfH1r1ADqtfSdVCToUG868RvUUkgDKf31mGDtKsAYz2oz2AGutZYs'
|
2020-12-09 12:35:02 +03:00
|
|
|
=fprint [%4 0xdead.beef]
|
|
|
|
:btc-wallet-store|action [%add-wallet scan-xpub fprint ~ [~ 3] [~ 6]]
|
2020-11-02 20:51:19 +03:00
|
|
|
:btc-wallet-store +dbug
|
|
|
|
:: shows scans with the xpub and {0 1 2} todos
|
2020-11-03 14:50:10 +03:00
|
|
|
|
|
|
|
:: %0 account has no used
|
2020-11-11 12:41:13 +03:00
|
|
|
=btc -build-file %/lib/btc/hoon
|
2020-12-04 21:54:59 +03:00
|
|
|
:btc-wallet-store|action [%address-info scan-xpub %0 1 *(set utxo:btc) used=%.n 655000]
|
|
|
|
:btc-wallet-store|action [%address-info scan-xpub %0 2 *(set utxo:btc) used=%.n 655000]
|
|
|
|
:btc-wallet-store|action [%address-info scan-xpub %0 0 *(set utxo:btc) used=%.n 655000]
|
2020-11-03 14:50:10 +03:00
|
|
|
:: dbug should give empty for scans: [xpub %0]
|
2020-12-04 21:54:59 +03:00
|
|
|
:btc-wallet-store|action [%address-info scan-xpub %1 2 *(set utxo:btc) used=%.n 655000]
|
|
|
|
:btc-wallet-store|action [%address-info scan-xpub %1 0 *(set utxo:btc) used=%.n 655000]
|
|
|
|
:btc-wallet-store|action [%address-info scan-xpub %1 1 *(set utxo:btc) used=%.y 655000]
|
2020-11-03 14:50:10 +03:00
|
|
|
:: dbug should show re-filled scans: [xpub %1]
|
2020-11-02 20:51:19 +03:00
|
|
|
```
|
|
|
|
|
2020-11-18 14:39:57 +03:00
|
|
|
|
2020-12-04 21:54:59 +03:00
|
|
|
## Address Generation Integration Test
|
|
|
|
All on `~zod`:
|
|
|
|
```
|
|
|
|
:btc-provider|command [%set-credentials api-url='http://localhost:50002']
|
|
|
|
:btc-wallet-hook|action [%set-provider ~zod]
|
|
|
|
=scan-xpub 'zpub6rFR7y4Q2AijBEqTUquhVz398htDFrtymD9xYYfG1m4wAcvPhXNfE3EfH1r1ADqtfSdVCToUG868RvUUkgDKf31mGDtKsAYz2oz2AGutZYs'
|
2020-12-09 11:56:38 +03:00
|
|
|
=fprint [%4 0xdead.beef]
|
|
|
|
:btc-wallet-store|action [%add-wallet scan-xpub fprint ~ [~ 3] [~ 6]]
|
2020-11-19 12:11:02 +03:00
|
|
|
|
2020-12-04 21:54:59 +03:00
|
|
|
:btc-wallet-store|action [%generate-address scan-xpub %0 meta=~]
|
2020-11-18 14:39:57 +03:00
|
|
|
```
|
2020-12-09 11:56:38 +03:00
|
|
|
:: make sure that the above address is watched
|
2020-12-04 21:54:59 +03:00
|
|
|
|
2020-11-18 14:39:57 +03:00
|
|
|
|
2020-11-24 22:30:41 +03:00
|
|
|
## Make a full TXBU
|
2020-11-26 12:38:30 +03:00
|
|
|
Provider is `~zod`, `~dopzod` is a client. Use the xpub from PRIVATE.md to have a balance
|
|
|
|
|
|
|
|
### setup
|
2020-11-24 22:30:41 +03:00
|
|
|
On `~zod`:
|
|
|
|
```
|
2020-11-26 12:38:30 +03:00
|
|
|
|start %btc-provider
|
|
|
|
|start %btc-wallet-store
|
|
|
|
|start %btc-wallet-hook
|
2020-11-24 22:30:41 +03:00
|
|
|
:btc-provider|command [%set-credentials api-url='http://localhost:50002']
|
|
|
|
:btc-provider|command [%whitelist-clients `(set ship)`(sy ~[~dopzod])]
|
2020-11-26 12:38:30 +03:00
|
|
|
=xpubzod 'zpub6rFR7y4Q2AijBEqTUquhVz398htDFrtymD9xYYfG1m4wAcvPhXNfE3EfH1r1ADqtfSdVCToUG868RvUUkgDKf31mGDtKsAYz2oz2AGutZYs'
|
|
|
|
:btc-wallet-hook|action [%set-provider ~zod]
|
|
|
|
:btc-wallet-store|action [%add-wallet xpubzod ~ [~ 20] [~ 6]]
|
2020-11-24 22:30:41 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
on `~dopzod`:
|
|
|
|
```
|
2020-11-26 12:38:30 +03:00
|
|
|
=xpubp PRIVATE.md
|
|
|
|
|
|
|
|
|start %btc-wallet-store
|
|
|
|
|start %btc-wallet-hook
|
2020-11-24 22:30:41 +03:00
|
|
|
:btc-wallet-hook|action [%set-provider ~zod]
|
2020-11-26 12:38:30 +03:00
|
|
|
:btc-wallet-store|action [%add-wallet xpubp ~ [~ 20] [~ 6]]
|
|
|
|
```
|
|
|
|
|
|
|
|
### request address
|
|
|
|
on `~dopzod`:
|
2020-11-24 22:30:41 +03:00
|
|
|
```
|
2020-11-26 12:38:30 +03:00
|
|
|
:btc-wallet-hook|action [%req-pay-address payee=~zod value=2.000 [~ 10]]
|
|
|
|
```
|
|
|
|
|
2020-11-18 14:39:57 +03:00
|
|
|
|
2020-11-11 12:41:13 +03:00
|
|
|
## scrys
|
|
|
|
```
|
|
|
|
.^((list @t) %gx /=btc-wallet-store=/scanned/noun)
|
2020-11-17 18:34:48 +03:00
|
|
|
|
|
|
|
.^(@ud %gx /=btc-wallet-store=/balance/[xpub]/noun)
|
2020-11-11 12:41:13 +03:00
|
|
|
```
|
2020-11-02 10:53:04 +03:00
|
|
|
|