mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-12 15:01:38 +03:00
working %create-raw-tx
This commit is contained in:
parent
a8cd63265d
commit
8c13a23b5f
@ -20,3 +20,12 @@
|
||||
:btc-provider|action ['reqid' %tx-info [%32 0x9ece.9c56.9ab3.27db.ada5.a51e.2653.7b3f.7e99.5579.c18a.af4f.8620.304b.ce53.16f1]]
|
||||
:: 4 inputs, one output
|
||||
```
|
||||
|
||||
## Generate a Raw TX from Inputs/Outputs
|
||||
```
|
||||
:btc-provider|command [%set-credentials api-url='http://localhost:50002']
|
||||
=inputs ~[[[%32 0xe86.8771.b3bf.f789.525e.21ba.c735.e280.70d1.eff0.fb4d.f59a.dc98.e914.8e2f.85d4] 0]]
|
||||
=outputs ~[[[%bech32 'bc1q0ydcskwye4rqky4qankhl4kegajl8nh50plmx0'] 12.500.000]]
|
||||
|
||||
:btc-provider|action ['rawtx0' %create-raw-tx inputs outputs]
|
||||
```
|
||||
|
@ -114,6 +114,9 @@
|
||||
::
|
||||
%raw-tx
|
||||
[%get-raw-tx txid.body.act]
|
||||
::
|
||||
%create-raw-tx
|
||||
[%create-raw-tx inputs.body.act outputs.body.act]
|
||||
::
|
||||
%ping
|
||||
[%get-block-and-fee ~]
|
||||
@ -173,6 +176,11 @@
|
||||
?> ?=([%get-raw-tx *] resp)
|
||||
:_ state
|
||||
~[(send-update [%.y (get-req-id wire) %raw-tx +.resp])]
|
||||
::
|
||||
[%create-raw-tx @ *]
|
||||
?> ?=([%get-raw-tx *] resp)
|
||||
:_ state
|
||||
~[(send-update [%.y (get-req-id wire) %raw-tx +.resp])]
|
||||
::
|
||||
[%ping @ *]
|
||||
?> ?=([%get-block-and-fee *] resp)
|
||||
|
@ -55,7 +55,7 @@
|
||||
def ~(. (default-agent this %|) bowl)
|
||||
hc ~(. +> bowl)
|
||||
::
|
||||
++ on-initb
|
||||
++ on-init
|
||||
^- (quip card _this)
|
||||
~& > '%btc-wallet-hook initialized'
|
||||
:_ this(fam-limit.state fam-limit:defaults)
|
||||
|
@ -22,6 +22,10 @@
|
||||
==
|
||||
~|("legacy addresses not yet supported" !!)
|
||||
[%bech32 addrc]
|
||||
::
|
||||
++ txid-to-cord
|
||||
|= =txid ^- cord
|
||||
(en:base16:mimes:html txid)
|
||||
:: +from-epoch: time since Jan 1, 1970 in seconds.
|
||||
::
|
||||
++ from-epoch
|
||||
@ -59,12 +63,52 @@
|
||||
^- request:http
|
||||
[%'GET' url ~ ~]
|
||||
::
|
||||
++ post-request
|
||||
|= [url=@t body=json]
|
||||
^- request:http
|
||||
:* %'POST'
|
||||
url
|
||||
~[['Content-Type' 'application/json']]
|
||||
=, html
|
||||
%- some
|
||||
%- as-octt:mimes
|
||||
(en-json body)
|
||||
==
|
||||
::
|
||||
++ gen-request
|
||||
|= [=host-info ract=action:rpc]
|
||||
^- request:http
|
||||
%+ rpc-action-to-http
|
||||
api-url.host-info ract
|
||||
::
|
||||
++ action-to-json
|
||||
|= ract=action:rpc
|
||||
|^ ^- json
|
||||
=, enjs:format
|
||||
?+ -.ract ~|("Unsupported action for POST" !!)
|
||||
%create-raw-tx
|
||||
%- pairs
|
||||
:~ [%inputs [%a (turn inputs.ract input)]]
|
||||
[%outputs [%a (turn outputs.ract output)]]
|
||||
==
|
||||
==
|
||||
::
|
||||
++ input
|
||||
|= [=txid pos=@ud]
|
||||
^- json
|
||||
=, enjs:format
|
||||
%- pairs
|
||||
:~ [%txid [%s (txid-to-cord txid)]]
|
||||
[%vout (numb pos)]
|
||||
==
|
||||
++ output
|
||||
|= [=address value=sats]
|
||||
=, enjs:format
|
||||
^- json
|
||||
%- frond
|
||||
[(address-to-cord address) (numb value)]
|
||||
--
|
||||
::
|
||||
++ to-response
|
||||
|= result:rpc
|
||||
^- result
|
||||
@ -85,6 +129,9 @@
|
||||
::
|
||||
%get-raw-tx
|
||||
[id.res (raw-tx res.res)]
|
||||
::
|
||||
%create-raw-tx
|
||||
[%get-raw-tx (raw-tx res.res)]
|
||||
::
|
||||
%get-block-count
|
||||
[id.res (ni:dejs:format res.res)]
|
||||
@ -136,24 +183,33 @@
|
||||
++ rpc-action-to-http
|
||||
|= [endpoint=@t ract=action:rpc]
|
||||
|^ ^- request:http
|
||||
%- get-request
|
||||
?- -.ract
|
||||
%get-address-info
|
||||
%- get-request
|
||||
%+ mk-url '/addresses/info/'
|
||||
(address-to-cord address.ract)
|
||||
::
|
||||
%get-tx-vals
|
||||
%- get-request
|
||||
%+ mk-url '/gettxvals/'
|
||||
(en:base16:mimes:html txid.ract)
|
||||
(txid-to-cord txid.ract)
|
||||
::
|
||||
%get-raw-tx
|
||||
%- get-request
|
||||
%+ mk-url '/getrawtx/'
|
||||
(en:base16:mimes:html txid.ract)
|
||||
(txid-to-cord txid.ract)
|
||||
::
|
||||
%create-raw-tx
|
||||
%+ post-request
|
||||
(mk-url '/createrawtx' '')
|
||||
(action-to-json ract)
|
||||
::
|
||||
%get-block-count
|
||||
%- get-request
|
||||
(mk-url '/getblockcount' '')
|
||||
::
|
||||
%get-block-and-fee
|
||||
%- get-request
|
||||
(mk-url '/getblockandfee' '')
|
||||
==
|
||||
++ mk-url
|
||||
|
@ -11,9 +11,12 @@
|
||||
$% [%address-info =address]
|
||||
[%tx-info =txid]
|
||||
[%raw-tx =txid]
|
||||
[%create-raw-tx inputs=(list [=txid pos=@ud]) outputs=(list [=address value=sats])]
|
||||
[%ping ~]
|
||||
==
|
||||
+$ result [=req-id body=result-body]
|
||||
:: %raw-tx: result type for both %raw-tx and %create-raw-tx actions
|
||||
::
|
||||
+$ result-body
|
||||
$% [%address-info utxos=(set utxo) used=? block=@ud]
|
||||
[%tx-info =info:tx]
|
||||
@ -39,6 +42,7 @@
|
||||
$% [%get-address-info =address]
|
||||
[%get-tx-vals =txid]
|
||||
[%get-raw-tx =txid]
|
||||
[%create-raw-tx inputs=(list [=txid pos=@ud]) outputs=(list [=address value=sats])]
|
||||
[%get-block-count ~]
|
||||
[%get-block-and-fee ~]
|
||||
==
|
||||
@ -47,6 +51,7 @@
|
||||
$% [%get-address-info utxos=(set utxo) used=? block=@ud]
|
||||
[%get-tx-vals =info:tx]
|
||||
[%get-raw-tx =txid =rawtx]
|
||||
[%create-raw-tx =rawtx]
|
||||
[%get-block-count block=@ud]
|
||||
[%get-block-and-fee block=@ud fee=sats]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user