Skip to content

Commit

Permalink
FIX: issue #61 (the sendtx api didnot work, resue btc.com api)
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbegin authored and qtxie committed Sep 4, 2019
1 parent 53d8750 commit e185143
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions libs/bitcoin.red
Original file line number Diff line number Diff line change
Expand Up @@ -226,17 +226,14 @@ btc: context [
]

publish-tx: function [network [url!] tx [string!]][
;url: rejoin [network "/tools/tx-publish"]
url: either find network "tchain" [ ;-- testnet
https://chain.so/api/v2/send_tx/BTCTEST
][
https://chain.so/api/v2/send_tx/BTC
]
body: rejoin ["tx_hex=" tx]
resp: load-json write url body
either resp/status = "success" [resp/data/txid][
new-error 'publish-tx "server error" resp
url: rejoin [network "/tools/tx-publish"]
body: make map! reduce ['rawhex tx]
resp: post-url url body
if 0 <> err-no: resp/err_no [
new-error 'publish-tx "server error" reduce [url err-no resp/err_msg]
]
wait 0.5
decode-tx network tx
]

decode-tx: function [network [url!] tx [string!]][
Expand Down

0 comments on commit e185143

Please sign in to comment.