mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-13 08:38:43 +03:00
tests work
This commit is contained in:
parent
236e923417
commit
9b013c5cf9
@ -1,5 +1,5 @@
|
||||
/- bp=btc-provider, json-rpc, bc=bitcoin
|
||||
/+ bcu=bitcoin-utils
|
||||
/- bp=btc-provider, json-rpc
|
||||
/+ bc=bitcoin
|
||||
^?
|
||||
::=< [sur .]
|
||||
::=, sur
|
||||
@ -64,7 +64,7 @@
|
||||
==
|
||||
++ address-info
|
||||
%- ot
|
||||
:~ [%address (cu from-cord:adr:bcu so)]
|
||||
:~ [%address (cu from-cord:adr:bc so)]
|
||||
[%utxos (as utxo)]
|
||||
[%used bo]
|
||||
[%block ni]
|
||||
@ -72,7 +72,7 @@
|
||||
++ utxo
|
||||
%- ot
|
||||
:~ ['tx_pos' ni]
|
||||
['tx_hash' (cu from-cord:hxb:bcu so)]
|
||||
['tx_hash' (cu from-cord:hxb:bc so)]
|
||||
[%height ni]
|
||||
[%value ni]
|
||||
[%recvd (cu from-epoch ni)]
|
||||
@ -80,7 +80,7 @@
|
||||
++ tx-vals
|
||||
%- ot
|
||||
:~ [%included bo]
|
||||
[%txid (cu from-cord:hxb:bcu so)]
|
||||
[%txid (cu from-cord:hxb:bc so)]
|
||||
[%confs ni]
|
||||
[%recvd (cu from-epoch ni)]
|
||||
[%inputs (ar tx-val)]
|
||||
@ -88,19 +88,19 @@
|
||||
==
|
||||
++ tx-val
|
||||
%- ot
|
||||
:~ [%txid (cu from-cord:hxb:bcu so)]
|
||||
:~ [%txid (cu from-cord:hxb:bc so)]
|
||||
[%pos ni]
|
||||
[%address (cu from-cord:adr:bcu so)]
|
||||
[%address (cu from-cord:adr:bc so)]
|
||||
[%value ni]
|
||||
==
|
||||
++ raw-tx
|
||||
%- ot
|
||||
:~ [%txid (cu from-cord:hxb:bcu so)]
|
||||
[%rawtx (cu from-cord:hxb:bcu so)]
|
||||
:~ [%txid (cu from-cord:hxb:bc so)]
|
||||
[%rawtx (cu from-cord:hxb:bc so)]
|
||||
==
|
||||
++ broadcast-tx
|
||||
%- ot
|
||||
:~ [%txid (cu from-cord:hxb:bcu so)]
|
||||
:~ [%txid (cu from-cord:hxb:bc so)]
|
||||
[%broadcast bo]
|
||||
[%included bo]
|
||||
==
|
||||
@ -108,8 +108,8 @@
|
||||
%- ot
|
||||
:~ [%block ni]
|
||||
[%fee (mu ni)]
|
||||
[%blockhash (cu from-cord:hxb:bcu so)]
|
||||
[%blockfilter (cu from-cord:hxb:bcu so)]
|
||||
[%blockhash (cu from-cord:hxb:bc so)]
|
||||
[%blockfilter (cu from-cord:hxb:bc so)]
|
||||
==
|
||||
--
|
||||
--
|
||||
@ -121,22 +121,22 @@
|
||||
%get-address-info
|
||||
%- get-request
|
||||
%+ mk-url '/addresses/info/'
|
||||
(to-cord:adr:bcu address.ract)
|
||||
(to-cord:adr:bc address.ract)
|
||||
::
|
||||
%get-tx-vals
|
||||
%- get-request
|
||||
%+ mk-url '/gettxvals/'
|
||||
(to-cord:hxb:bcu txid.ract)
|
||||
(to-cord:hxb:bc txid.ract)
|
||||
::
|
||||
%get-raw-tx
|
||||
%- get-request
|
||||
%+ mk-url '/getrawtx/'
|
||||
(to-cord:hxb:bcu txid.ract)
|
||||
(to-cord:hxb:bc txid.ract)
|
||||
::
|
||||
%broadcast-tx
|
||||
%- get-request
|
||||
%+ mk-url '/broadcasttx/'
|
||||
(to-cord:hxb:bcu rawtx.ract)
|
||||
(to-cord:hxb:bc rawtx.ract)
|
||||
::
|
||||
%get-block-count
|
||||
%- get-request
|
||||
|
@ -1,7 +1,7 @@
|
||||
:: lib/btc-wallet.hoon
|
||||
::
|
||||
::
|
||||
/- *btc-wallet, bc=bitcoin
|
||||
/+ bip32, bcu=bitcoin-utils, bp=btc-provider, pbt=bip-b174
|
||||
/- *btc-wallet
|
||||
/+ bip32, bc=bitcoin, bp=btc-provider
|
||||
=, secp:crypto
|
||||
=+ ecc=secp256k1
|
||||
|%
|
||||
@ -31,7 +31,7 @@
|
||||
confs=(unit @ud)
|
||||
==
|
||||
^- walt
|
||||
=/ [=bipt =network] (xpub-type:bcu xpub)
|
||||
=/ [=bipt =network] (xpub-type:bc xpub)
|
||||
:* xpub
|
||||
network
|
||||
fprint
|
||||
@ -99,13 +99,13 @@
|
||||
::
|
||||
++ vbytes
|
||||
^- vbytes:bc
|
||||
%+ add overhead-weight:bcu
|
||||
%+ add overhead-weight:bc
|
||||
%+ add
|
||||
%+ roll
|
||||
(turn txis.t |=(t=txi (input-weight:bcu bipt.hdkey.t)))
|
||||
(turn txis.t |=(t=txi (input-weight:bc bipt.hdkey.t)))
|
||||
add
|
||||
%+ roll
|
||||
(turn txos.t |=(t=txo (output-weight:bcu (get-bipt:adr:bcu address.t))))
|
||||
(turn txos.t |=(t=txo (output-weight:bc (get-bipt:adr:bc address.t))))
|
||||
add
|
||||
++ tx-data
|
||||
|^
|
||||
@ -122,16 +122,16 @@
|
||||
==
|
||||
++ txo-data
|
||||
|= =txo
|
||||
:- (to-script-pubkey:adr:bcu address.txo)
|
||||
:- (to-script-pubkey:adr:bc address.txo)
|
||||
value.txo
|
||||
--
|
||||
::
|
||||
++ get-txid
|
||||
^- txid
|
||||
(get-id:txu:bcu tx-data)
|
||||
(get-id:txu:bc tx-data)
|
||||
::
|
||||
++ get-rawtx
|
||||
(basic-encode:txu:bcu tx-data)
|
||||
(basic-encode:txu:bc tx-data)
|
||||
:: +add-output: append output (usually change) to txos
|
||||
::
|
||||
++ add-output
|
||||
@ -154,7 +154,7 @@
|
||||
=/ outs=(list out:psbt:bc)
|
||||
%+ turn txos.t
|
||||
|=(=txo [address.txo hk.txo])
|
||||
`(encode:pbt %.y get-rawtx get-txid ins outs)
|
||||
`(encode:pbt:bc %.y get-rawtx get-txid ins outs)
|
||||
--
|
||||
:: wad: door for processing walts (wallets)
|
||||
:: parameterized on a walt and it's chyg account
|
||||
@ -177,7 +177,7 @@
|
||||
++ mk-address
|
||||
|= =idx:bc
|
||||
^- address:bc
|
||||
(from-pubkey:adr:bcu bipt.w network.w (pubkey idx))
|
||||
(from-pubkey:adr:bc bipt.w network.w (pubkey idx))
|
||||
:: +nixt-address: used to get change addresses
|
||||
:: - gets the current next available address
|
||||
:: - doesn't bump nixt-address if it's unused
|
||||
@ -258,7 +258,7 @@
|
||||
++ dust-threshold
|
||||
|= output-bipt=bipt:bc
|
||||
^- vbytes
|
||||
(mul dust-sats (input-weight:bcu output-bipt))
|
||||
(mul dust-sats (input-weight:bc output-bipt))
|
||||
::
|
||||
++ target-value
|
||||
^- sats
|
||||
@ -267,24 +267,24 @@
|
||||
::
|
||||
++ base-weight
|
||||
^- vbytes
|
||||
%+ add overhead-weight:bcu
|
||||
%+ add overhead-weight:bc
|
||||
%+ roll
|
||||
%+ turn txos
|
||||
|=(=txo (output-weight:bcu (get-bipt:adr:bcu address.txo)))
|
||||
|=(=txo (output-weight:bc (get-bipt:adr:bc address.txo)))
|
||||
add
|
||||
::
|
||||
++ total-vbytes
|
||||
|= selected=(list insel)
|
||||
^- vbytes
|
||||
%+ add base-weight
|
||||
(mul (input-weight:bcu bipt.w) (lent selected))
|
||||
(mul (input-weight:bc bipt.w) (lent selected))
|
||||
:: value of an input after fee
|
||||
:: 0 if net is <= 0
|
||||
::
|
||||
++ net-value
|
||||
|= val=sats
|
||||
^- sats
|
||||
=/ cost (mul (input-weight:bcu bipt.w) feyb)
|
||||
=/ cost (mul (input-weight:bc bipt.w) feyb)
|
||||
?: (lte val cost) 0
|
||||
(sub val cost)
|
||||
::
|
||||
@ -303,7 +303,7 @@
|
||||
?~ tb [~ ~]
|
||||
=+ excess=~(fee txb u.tb) :: (inputs - outputs)
|
||||
=/ new-fee=sats :: cost of this tx + one more output
|
||||
(mul feyb (add (output-weight:bcu bipt.w) vbytes.u.tb))
|
||||
(mul feyb (add (output-weight:bc bipt.w) vbytes.u.tb))
|
||||
?. (gth excess new-fee)
|
||||
[tb ~]
|
||||
?. (gth (sub excess new-fee) (dust-threshold bipt.w))
|
||||
@ -317,7 +317,7 @@
|
||||
?. %+ levy txos
|
||||
|= =txo
|
||||
%+ gth value.txo
|
||||
(dust-threshold (get-bipt:adr:bcu address.txo))
|
||||
(dust-threshold (get-bipt:adr:bc address.txo))
|
||||
~|("One or more suggested outputs is dust." !!)
|
||||
=/ is=(unit (list insel))
|
||||
%- single-random-draw
|
||||
|
Loading…
Reference in New Issue
Block a user