From a35b010851a6cdbff61f6350aa8fbe88af6e93e0 Mon Sep 17 00:00:00 2001 From: timlucmiptev Date: Thu, 28 Jan 2021 13:03:53 +0200 Subject: [PATCH] done w initial cleanup --- BTC.scratch.md | 254 -------------------------------------- DEMO.md | 6 +- MOON_INSTALL.md | 6 +- PATCH.md | 18 --- TEST.md | 5 + WALLET.scratch.md | 130 ------------------- app/btc-provider.hoon | 8 +- app/btc-wallet-hook.hoon | 2 - lib/btc-wallet-store.hoon | 4 +- sur/btc-provider.hoon | 3 +- sur/btc-wallet-hook.hoon | 2 +- 11 files changed, 20 insertions(+), 418 deletions(-) delete mode 100644 BTC.scratch.md delete mode 100644 PATCH.md delete mode 100644 WALLET.scratch.md diff --git a/BTC.scratch.md b/BTC.scratch.md deleted file mode 100644 index f6c747632..000000000 --- a/BTC.scratch.md +++ /dev/null @@ -1,254 +0,0 @@ -## Legacy BTC Address Parsing -``` - -:: yields the initial addresss -`@uc`(scan "17xg1BZLn63zCxdTxbsFLoWpQeSnD7zSHW" fim:ag) - -:: as a cord -`@t`(scot %uc `@uc`(scan "17xg1BZLn63zCxdTxbsFLoWpQeSnD7zSHW" fim:ag)) -``` - -## sha256 Implementation -This is needed for hashing to/from big endian, possibly with leading and trailing 0s. - -We use 20 byte value `0x7f5a.997b.83f5.1f79.3b89.10be.9950.8b00.a136.f900` - -### JS Reference Values -``` -val = "7f5a997b83f51f793b8910be99508b00a136f900"; -b = Buffer.from(val, "hex"); -createHash('sha256').update(b).digest(); -// yields: - -val2 = "007f5a997b83f51f793b8910be99508b00a136f900"; -b2 = Buffer.from(val2, "hex"); -createHash('sha256').update(b2).digest(); -// yields: -``` - -In the Hoon version, we indicate leading zeros by increasing the byte count, rather than with a string -``` -:: trailing 0s -=val 0x7f5a.997b.83f5.1f79.3b89.10be.9950.8b00.a136.f900 -`@ux`dat:(sha256:btc 20 val) -:: gives 0x4d9a.8e9b.966c.f83a.695c.607b.c323.74a0.d270.35aa.52a0.b673.8dc4.73fe.95c6.8fb3 - -:: leading 0s--pass 21 as byte count -`@ux`dat:(sha256:btc 21 val) -:: gives 0x66ee.cb4f.b50e.9d93.f85e.7869.6a34.097a.b859.fbc9.b7f6.f087.3329.423b.5fdd.8072 -``` - -## Byte Buffers -Makes it easy to concatenate hex sequences with leading 0s, and then convert them back to bytes for hashing. - -### JS Reference -``` -b = Buffer.from("000000000000ff00", "hex"); -createHash('sha256').update(b).digest() -// yields: -``` - -Hoon: -``` -=b (from-byts:buffer:btc [8 0xff00]) -`[@ @ux]`(sha256:btc (to-byts:buffer:btc b)) - -:: gives [32 0xe883.e86b.ffeb.ac72.cc7d.320a.b72f.e1e5.5c19.9d55.d841.bf43.cbd8.03c5.55a7.1006] -``` - -## 8bit to 5bit conversion, and back again -Start with a Hash160 (8bit hex). Convert to bech32. Decode the bech32, drop the leading 0, and run through `digits-to-atom`. - -### 8 bits to 5 bits - -### 5 bits to 8 bits -``` -:: base32: -=val ~[0 0 31 31 31 31 0 0] -(from-digits:bits:btc 5 val) -:: gives ~[0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0] - -`@ux`(to-atom:bits:btc (from-digits:bits:btc 5 val)) -:: gives 0x3fff.fc00 -``` - -## BIP 173 (Bech32 Addresses) -``` -=btc -build-file %/lib/btc/hoon -``` - -### Bech32 Algo -- hash = hash160(pubkey) -- 5-bit-words = convert-bits(8, 5, hash-atom) -- encode("bc", [0, 5-bit-words]) - -### BTC pubkey -> address hashing (Hash-160) -Uses the example data here: -https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses - -That one starts with pubkey below. The following runs it through sha256 and ripemd160 to get Hash-160: -``` -``` - -Use `@uc` to make the Hash-160 into a BTC P2PKH address -``` -=pubkey 0x2.5086.3ad6.4a87.ae8a.2fe8.3c1a.f1a8.403c.b53f.53e4.86d8.511d.ad8a.0488.7e5b.2352 -(hash-160:btc pubkey) -:: gives [%20 0xf54a.5851.e937.2b87.810a.8e60.cdd2.e7cf.d80b.6e31] - -`@uc`dat:(hash-160:btc pubkey) -:: gives 1PMycacnJaSqwwJqjawXBErnLsZ7RkXUAs -``` -0x3.724a.a081.bd67.a2bd.7dc3.a4b6.a36d.69c2.c148.483e.27bd.50dc.7ee7.27f9.dc87.b8b4 -0x3.fda0.6514.80ec.ac75.cd91.ec65.7123.9a24.c657.cc25.f0f8.def2.0554.5230.2d12.6488 - -### trailing zero -Need to test with this because it shows need to input num bytes -``` -0x3.f3c1.3839.3683.93e7.0caf.4148.4775.b805.312d.58be.d157.1308.3d27.5cf5.6998.0100 -``` - -### bip173 test pubkey -The below code also shows how to convert from bech32 back to a 20-byte hash. This is used for transaction building. -``` -=pubkey 0x2.79be.667e.f9dc.bbac.55a0.6295.ce87.0b07.029b.fcdb.2dce.28d9.59f2.815b.16f8.1798 -(encode-pubkey:bech32:btc %main pubkey)bbt -:: gives [~ %bech32 'bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4'] - -`[@ @ux]`(hash-160:btc pubkey) -:: gives [20 0x751e.76e8.1991.96d4.5494.1c45.d1b3.a323.f143.3bd6] - -(encode-hash-160:bech32:btc %main (hash-160:btc pubkey)) -:: gives [~ %bech32 'bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4'] -``` - -### Decode Bech32 to hex -Return val as `byts` to preserve leading zeros. -``` -(decode-raw:bech32:btc [%bech32 'bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4']) -:: prints data: ~[0 14 20 15 7 13 26 0 25 18 6 11 13 8 21 4 20 3 17 2 29 3 12 29 3 4 15 24 20 6 14 30 22] - -(to-hex:bech32:btc [%bech32 'bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4']) -:: gives [20 0x751e.76e8.1991.96d4.5494.1c45.d1b3.a323.f143.3bd6] -``` - -### bip84 public keys -From seed mnemonic: -``` -process child keen cargo design install parrot hold pole unveil dance reason drink cash fix - -0x2.88b5.a58a.5c26.6cef.d41b.f329.9165.46cc.1703.c4d9.a32e.1ea3.ef3d.1823.c493.05ac -0x3.289a.4e24.4381.8992.fe20.0831.3551.a3af.2266.ef3d.2038.5df9.6daa.g92e3.4df2.16c4 -0x3.109a.2082.eaa6.8925.1465.5393.d635.7fb9.d9b5.e191.3826.8837.69cd.db88.7a4b.b4f0 -``` - -## TX Hashing -Final TXID: `0x33f.693f.df99.5a5e.a7fe.5c95.1ab6.858c.7e6a.5fff.c585.7992.2cd4.fc31.9c61.4c5b` -Can lookup in blockchain as: -033f693fdf995a5ea7fe5c951ab6858c7e6a5fffc58579922cd4fc319c614c5b -``` -=btc -build-file %/lib/btc/hoon=btc -build-file %/lib/btc/hoon -=in0 [%32^0x3d6a.f8a8.32b2.ef3f.82f4.dd9c.ccc9.a5af.23db.dbe9.2eae.86f0.7b06.fd41.9525.62b5 62 4^0xffff.ffff ~ ~ 10.950.904] -=out0 [script-pubkey=(script-pubkey:btc [%bech32 'bc1q59u5epktervh6fxqay2dlph0wxu9hjnx6v8n66']) value=10.944.414] - -(get-id:txu:btc [~[in0] ~[out0] 0 1 ~]) -``` - -## TX Decoding/Parsing -Signed TX: -`01000000000101bee955e95966c35c9b4f1b9b59b8d84b61044b1b6c5d5c380c3b6ed8938c1d6d0000000000ffffffff01385cb01000000000160014ea13bc0f69262d7ab1cb307668105473754b23bc0247304402204c0a3c2aed0d4fc7b6e9b70cc9bd0e489aa82547419ba7a209e5552d6659e2740220158043b25a7342cc231b15eb39217b29decc7d3ca55953f47a0461b3eb0255b2012102b791e56d195e0b597c84d351953176a255019dd5d0ad8b6210fa590d20f45b4c00000000` - -TXID: -c6288b657f197a173cda7e1d2ba977ad03a465bba778bd8b66e7f3389c8ec3dd -``` -=signed-tx 191^0x1.0000.0000.0101.bee9.55e9.5966.c35c.9b4f.1b9b.59b8.d84b.6104.4b1b.6c5d.5c38.0c3b.6ed8.938c.1d6d.0000.0000.00ff.ffff.ff01.385c.b010.0000.0000.1600.14ea.13bc.0f69.262d.7ab1.cb30.7668.1054.7375.4b23.bc02.4730.4402.204c.0a3c.2aed.0d4f.c7b6.e9b7.0cc9.bd0e.489a.a825.4741.9ba7.a209.e555.2d66.59e2.7402.2015.8043.b25a.7342.cc23.1b15.eb39.217b.29de.cc7d.3ca5.5953.f47a.0461.b3eb.0255.b201.2102.b791.e56d.195e.0b59.7c84.d351.9531.76a2.5501.9dd5.d0ad.8b62.10fa.590d.20f4.5b4c.0000.0000 - -(get-id:txu:btc (decode:txu:btc signed-tx)) -``` - -## Unsigned Transactions -Using [BIP 143](https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki#P2SHP2WPKH) as a reference. - -Native P2WPKH -``` -=btc -build-file %/lib/btc/hoon -=input0 (input:tx:btc [[32 0xfff7.f788.1a80.99af.a694.0d42.d1e7.f636.2bec.3817.1ea3.edf4.3354.1db4.e4ad.969f] 0 0 [4 0xeeff.ffff] [35 0x21.03c9.f483.6b9a.4f77.fc0d.81f7.bcb0.1b7f.1b35.9168.64b9.476c.241c.e9fc.198b.d254.32ac] ~ ~ 625.000.000]) -=input1 (input:tx:btc[[32 0xef51.e1b8.04cc.89d1.82d2.7965.5c3a.a89e.815b.1b30.9fe2.87d9.b2b5.5d57.b90e.c68a] 0 1 [4 0xffff.ffff] [22 0x14.1d0f.172a.0ecb.48ae.e1be.1f26.87d2.963a.e33f.71a1] ~ `[33 0x2.5476.c2e8.3188.368d.a1ff.3e29.2e7a.cafc.db35.66bb.0ad2.53f6.2fc7.0f07.aeee.6357] 600.000.000]) - -=output0 (output:tx:btc [[%bech32 'bc1qs2qtxl0n0rdenan0shy457p6w6k85m2e36f7ze'] 112.340.000]) -=output1 (output:tx:btc [[%bech32 'bc1q800y9klw0exmu63pkt2sechszel64q2enddkt4'] 223.450.000]) -=utx (unsigned:tx:btc [1 0x11 ~[input0 input1] ~[output0 output1]]) - -(~(sighash unsigned-tx:btc utx) 1) -:: gives [wid=32 dat=0xc37a.f311.16d1.b27c.af68.aae9.e3ac.82f1.4779.2901.4d5b.9176.57d0.eb49.478c.b670] -``` - -### Signing the above -Signing input index 1 (witness) -``` -=ecc secp256k1:secp:crypto -=h dat:(~(sighash unsigned-tx:btc utx) 1) -=privkey 0x619c.3350.25c7.f401.2e55.6c2a.58b2.506e.30b8.511b.53ad.e95e.a316.fd8c.3286.feb9 - -`@ux`(compress-point:ecc (priv-to-pub:ecc privkey)) -`[@ r=@ux s=@ux]`(ecdsa-raw-sign:ecc (@uvI h) privkey) -:: compress-point gives 0x2.5476.c2e8.3188.368d.a1ff.3e29.2e7a.cafc.db35.66bb.0ad2.53f6.2fc7.0f07.aeee.6357 -:: pubkey gives -:: desired r of sig: -:: 0x3609.e17b.84f6.a7d3.0c80.bfa6.10b5.b454.2f32.a8a0.d544.7a12.fb13.66d7.f01c.c44a -:: -:: desired s of sig: -:: 573a954c4518331561406f90300e8f3358f51928d43c212a8caed02de67eebee -``` - -Signing input index 0 (non-witness) -``` -=h2 dat:(~(sighash unsigned-tx:btc utx) 0) -=privkey2 0xbbc2.7228.ddcb.9209.d7fd.6f36.b02f.7dfa.6252.af40.bb2f.1cbc.7a55.7da8.027f.f866 -`[@ r=@ux s=@ux]`(ecdsa-raw-sign:ecc (@uvI h2) privkey2) - -:: desired r; -:: 0x8b9d.1dc2.6ba6.a9cb.6212.7b02.742f.a9d7.54cd.3beb.f337.f7a5.5d11.4c8e.5cdd.30be -``` - -### A sample legacy address-only transaction -``` -=linput0 (input:tx:btc [[32 0xeccf.7e30.3418.9b85.1985.d871.f913.84b8.ee35.7cd4.7c30.2473.6e56.76eb.2deb.b3f2] 1 0 [4 0xffff.ffff] [25 0x76.a914.0109.6677.6006.953d.5567.439e.5e39.f86a.0d27.3bee.88ac] ~ ~ 100.000.000]) -=loutput0 (output:tx:btc [[%legacy 0c1runeksijzfVxyrpiyCY2LCBvYsSiFsCm] 99.900.000]) -=lutx (unsigned:tx:btc [1 0x0 ~[linput0] ~[loutput0]]) - -=lh dat:(~(sighash unsigned-tx:btc lutx) 0) -=lprivkey 0x18e1.4a7b.6a30.7f42.6a94.f811.4701.e7c8.e774.e7f9.a47e.2c20.35db.29a2.0632.1725 -`[@ r=@ux s=@ux]`(ecdsa-raw-sign:ecc (@uvI lh) lprivkey) -``` -0x970.7252.4438.d003.d23a.2f23.edb6.5aae.1bb3.e469 - -### BIP143 Reference -https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki#P2SHP2WPKH - -## more scratch - -## Sponsorship for Stars/Planets -``` -> (clan:title our) -%king -> (clan:title ~timluc) -%king -> (clan:title ~timluc-miptev) -%duke -> (clan:title ~zod) -%czar -> (clan:title ~fipdul-podfer-bacdul-timzod) -%earl -(clan:title ~lapfep-tipdys-difsum-natmug--novpub-matwes-sicrel-marzod) -%pawn - -:: sponsorship -> (sein:title our now ~timluc-miptev) -~panten -> (saxo:title our now ~timluc-miptev) -~[~timluc-miptev ~panten ~ten] -``` - - -0x3.826c.6c98.6c28.1223.15e7.008b.333e.5c66.fec0.5475.a01f.dfee.1414.d455.2b46.28ee diff --git a/DEMO.md b/DEMO.md index 46c5483be..071f7c86a 100644 --- a/DEMO.md +++ b/DEMO.md @@ -16,8 +16,8 @@ On `~zod` |start %btc-wallet-hook |start %btc-wallet-store -:btc-provider|command [%set-credentials api-url='http://localhost:50002'] -:btc-wallet-hook|action [%set-provider ~zod] +:btc-provider|command [%set-credentials api-url='http://localhost:50002' %main] +:btc-wallet-hook|action [%set-provider ~zod %main] :btc-provider|command [%whitelist-clients `(set ship)`(sy ~[~dopzod])] ``` @@ -26,7 +26,7 @@ On `~dopzod` |commit %home |start %btc-wallet-hook |start %btc-wallet-store -:btc-wallet-hook|action [%set-provider ~zod] +:btc-wallet-hook|action [%set-provider ~zod %main] ``` ### Add Wallets diff --git a/MOON_INSTALL.md b/MOON_INSTALL.md index 79244eceb..40726c8d2 100644 --- a/MOON_INSTALL.md +++ b/MOON_INSTALL.md @@ -42,10 +42,10 @@ Install files: |start %btc-provider |start %btc-wallet-store |start %btc-wallet-hook -:btc-provider|command [%set-credentials api-url='http://localhost:50002'] +:btc-provider|command [%set-credentials api-url='http://localhost:50002' %main] :btc-provider|command [%whitelist-clients `(set ship)`(sy ~[moon2])] =xpub1 'zpub6rFR7y4Q2AijBEqTUquhVz398htDFrtymD9xYYfG1m4wAcvPhXNfE3EfH1r1ADqtfSdVCToUG868RvUUkgDKf31mGDtKsAYz2oz2AGutZYs' -:btc-wallet-hook|action [%set-provider moon1] +:btc-wallet-hook|action [%set-provider moon1 %main] =fprint [%4 0xdead.beef] :btc-wallet-store|action [%add-wallet xpub1 fprint ~ [~ 8] [~ 6]] @@ -60,7 +60,7 @@ Install files: |start %btc-wallet-store |start %btc-wallet-hook -:btc-wallet-hook|action [%set-provider moon1] +:btc-wallet-hook|action [%set-provider moon1 %main] =xpub2 'zpub6r8dKyWJ31XF6n69KKeEwLjVC5ruqAbiJ4QCqLsrV36Mvx9WEjUaiPNPGFLHNCCqgCdy6iZC8ZgHsm6a1AUTVBMVbKGemNcWFcwBGSjJKbD' =fprint [%4 0xbeef.dead] :btc-wallet-store|action [%add-wallet xpub2 fprint ~ [~ 8] [~ 1]] diff --git a/PATCH.md b/PATCH.md deleted file mode 100644 index 46805a70a..000000000 --- a/PATCH.md +++ /dev/null @@ -1,18 +0,0 @@ -zuze patch: -```hoon -++ decompress-point - |= dat=@ - ^- pont -:: ~& "custom decompress point" - =+ x=(end 3 w dat) - ?> =(3 (mod ^p 4)) - =+ y=(exp.p (div +(^p) 4) :(sum.p (exp.p 3 x) (pro.p a x) b)) - =+ s=(rsh 3 32 dat) - ~| [`@ux`s `@ux`dat] - ?> |(=(2 s) =(3 s)) - :: check parity - :: - =? y !=((sub s 2) (mod y 2)) - (sub ^p y) - [x y] -``` diff --git a/TEST.md b/TEST.md index d498cbc76..c0ebc2424 100644 --- a/TEST.md +++ b/TEST.md @@ -1,5 +1,10 @@ # Tests +``` +|commit %home +=btc -build-file %/lib/btc/hoon +``` + ## BTC libs ``` |commit %home diff --git a/WALLET.scratch.md b/WALLET.scratch.md deleted file mode 100644 index bdce1a972..000000000 --- a/WALLET.scratch.md +++ /dev/null @@ -1,130 +0,0 @@ -# btc-wallet-* Scratch Code - -## xpub -xpub1 is from mnemonic from PRIVATE.scratch -``` -=bl -build-file %/lib/btc-wallet-store/hoon -=xpub1 'zpub6r8dKyWJ31XF6n69KKeEwLjVC5ruqAbiJ4QCqLsrV36Mvx9WEjUaiPNPGFLHNCCqgCdy6iZC8ZgHsm6a1AUTVBMVbKGemNcWFcwBGSjJKbD' -=xpub2 'xpub6D7yaZieZEeG617UcKXDhbsDeso6bmxSAiGWkvkASoiwcjaRtrH5HeNRnDT25s7zmxYzj6MtFe32dVqcf9YcBKKgn9THHjwn2uSjkvobK4e' -=bl -build-file %/lib/btc-wallet-store/hoon -``` - -### get address at indices -``` -=walt1 (from-xpub:bl xpub1 [%4 0x5566.7788] ~ ~ ~) -(~(mk-address wad:bl walt1 %0) 0) -:: gives [%bech32 'bc1q0adfj7ur750hjwufzzlfj5ytqzsnd7fz9fjuzc'] -``` - -### update address data -``` -=walt1 (from-xpub:bl xpub1 ~ ~ ~) -(~(mk-address wad:bl walt1 %0) 0) -:: gives bc1q0adfj7ur750hjwufzzlfj5ytqzsnd7fz9fjuzc -=walt1 (~(watch-address wad:bl walt1 %0) [%bech32 'bc1q0adfj7ur750hjwufzzlfj5ytqzsnd7fz9fjuzc'] [%0 0 ~]) -nixt.walt1 -:: gives [p=1 q=0] (nixt updated since it was 0) -=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 -:: gives [p=1 q=0] (no update) -=walt1 (~(watch-address wad:bl walt1 %0) [%bech32 'bc1qvqrdh8suyv63ntaa0d7hmcamavv8283sngh6e5'] [%0 1 ~]) -nixt.walt1 -:: gives [p=3 q=0] (skips index 2, since already a used address there) - -=walt1 (~(watch-address wad:bl walt1 %0) [%bech32 'bc1qvqrdh8suyv63ntaa0d7hmcamavv8283sngh6e5'] [%0 4 ~]) -:: gives error, because address is inserted at index that doesn't match it -``` - -### generate new address (for receiving payment) -``` -=walt1 (from-xpub:bl xpub1 ~ ~) -=res ~(gen-address wad:bl walt1 %0) -p.res -nixt.q.res -:: gives -:: [%bech32 'bc1q0adfj7ur750hjwufzzlfj5ytqzsnd7fz9fjuzc'] -:: [p=1 q=0] -``` - -## Scanning -Mnemonic -``` -abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about -``` - -## 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' -=fprint [%4 0xdead.beef] -:btc-wallet-store|action [%add-wallet scan-xpub fprint ~ [~ 3] [~ 6]] - -:btc-wallet-store|action [%generate-address scan-xpub %0 meta=~] -``` -:: make sure that the above address is watched - - -## Make a full TXBU -Provider is `~zod`, `~dopzod` is a client. Use the xpub from PRIVATE.md to have a balance - -### setup -On `~zod`: -``` -|commit %home - -|start %btc-provider -|start %btc-wallet-store -|start %btc-wallet-hook -:btc-provider|command [%set-credentials api-url='http://localhost:50002'] -:btc-provider|command [%whitelist-clients `(set ship)`(sy ~[~dopzod])] -=xpubzod 'zpub6rFR7y4Q2AijBEqTUquhVz398htDFrtymD9xYYfG1m4wAcvPhXNfE3EfH1r1ADqtfSdVCToUG868RvUUkgDKf31mGDtKsAYz2oz2AGutZYs' -:btc-wallet-hook|action [%set-provider ~zod] - -=fprint [%4 0xdead.beef] -:btc-wallet-store|action [%add-wallet xpubzod fprint ~ [~ 8] [~ 6]] -``` - -on `~dopzod`: -``` -:: xpub from PRIVATE.md - -|commit %home - -|start %btc-wallet-store -|start %btc-wallet-hook -:btc-wallet-hook|action [%set-provider ~zod] -=xpubp 'zpub6r8dKyWJ31XF6n69KKeEwLjVC5ruqAbiJ4QCqLsrV36Mvx9WEjUaiPNPGFLHNCCqgCdy6iZC8ZgHsm6a1AUTVBMVbKGemNcWFcwBGSjJKbD' -=fprint [%4 0xbeef.dead] -:btc-wallet-store|action [%add-wallet xpubp fprint ~ [~ 8] [~ 6]] -``` - -### request address -on `~dopzod`: -``` -:btc-wallet-hook|action [%req-pay-address payee=~zod value=2.000 [~ 30]] -:btc-wallet-hook +dbug [%state 'poym'] -``` - -Sign the tx, then paste: -``` -=tx TXHEX -:btc-wallet-hook|action [%broadcast-tx tx] -``` - -### Send Transaction - -Check wallet store -``` -:btc-wallet-store +dbug [%state 'history'] -``` - -## scrys -``` -.^((list @t) %gx /=btc-wallet-store=/scanned/noun) - -.^(@ud %gx /=btc-wallet-store=/balance/[xpubp]/noun) -``` - diff --git a/app/btc-provider.hoon b/app/btc-provider.hoon index 7683a9dff..8db23927c 100644 --- a/app/btc-provider.hoon +++ b/app/btc-provider.hoon @@ -30,8 +30,8 @@ :: ++ on-init ^- (quip card _this) - ~& > '%btc-provider initialized successfully' - `this(host-info ['' connected=%.n block=0 clients=*(set ship)], whitelist *(set ship)) + ~& > '%btc-provider initialized successfully' + `this(host-info ['' connected=%.n %main block=0 clients=*(set ship)], whitelist *(set ship)) ++ on-save ^- vase !>(state) @@ -60,7 +60,7 @@ ?. (is-whitelisted:hc src.bowl) ~& >>> "btc-provider: blocked client {}" [~[[%give %kick ~ ~]] this] - ~& > "btc-provider: added client {}" + ~& > "btc-provider: accepted client {}" :- do-ping:hc this(clients.host-info (~(put in clients.host-info) src.bowl)) :: @@ -91,7 +91,7 @@ ?- -.comm %set-credentials :- do-ping - state(host-info [api-url.comm connected=%.n block=0 clients=*(set ship)]) + state(host-info [api-url.comm connected=%.n network.comm block=0 clients=*(set ship)]) :: %whitelist-clients `state(whitelist (~(uni in whitelist) clients.comm)) diff --git a/app/btc-wallet-hook.hoon b/app/btc-wallet-hook.hoon index cd4c16296..4dacfa01a 100644 --- a/app/btc-wallet-hook.hoon +++ b/app/btc-wallet-hook.hoon @@ -315,11 +315,9 @@ ?. =(host.u.prov src.bowl) `state ?- -.s %new-block - ~& >> "%new-block" (connected u.prov block.s fee.s `blockhash.s `blockfilter.s) :: %connected - ~& >> "%connected" (connected u.prov block.s fee.s ~ ~) :: %disconnected diff --git a/lib/btc-wallet-store.hoon b/lib/btc-wallet-store.hoon index 938db4492..76dfdf755 100644 --- a/lib/btc-wallet-store.hoon +++ b/lib/btc-wallet-store.hoon @@ -18,18 +18,18 @@ :: ++ from-xpub |= $: =xpub:btc - =network:btc =fprint:btc scan-to=(unit scon) max-gap=(unit @ud) confs=(unit @ud) == ^- walt + =/ [=bipt =network] (xpub-type:btc xpub) :* xpub network fprint (from-extended:bip32 (trip xpub)) - (xpub-type:btc xpub) + bipt *wach [0 0] %.n diff --git a/sur/btc-provider.hoon b/sur/btc-provider.hoon index e339abe6b..9316ea371 100644 --- a/sur/btc-provider.hoon +++ b/sur/btc-provider.hoon @@ -3,11 +3,12 @@ +$ host-info $: api-url=@t connected=? + =network block=@ud clients=(set ship) == +$ command - $% [%set-credentials api-url=@t] + $% [%set-credentials api-url=@t =network] [%whitelist-clients clients=(set ship)] == +$ action diff --git a/sur/btc-wallet-hook.hoon b/sur/btc-wallet-hook.hoon index b35a72f71..2378eb75d 100644 --- a/sur/btc-wallet-hook.hoon +++ b/sur/btc-wallet-hook.hoon @@ -35,7 +35,7 @@ peer == +$ settings - $% [%set-provider provider=ship] + $% [%set-provider provider=ship =network] [%set-default-wallet ~] [%clear-poym ~] [%force-retry ~]