diff --git a/pkg/arvo/app/btc-wallet.hoon b/pkg/arvo/app/btc-wallet.hoon index 77bcfcecca..6ee1530757 100644 --- a/pkg/arvo/app/btc-wallet.hoon +++ b/pkg/arvo/app/btc-wallet.hoon @@ -334,7 +334,8 @@ ?~ txbu.poym %.n =((get-id:txu:bc (decode:txu:bc signed)) ~(get-txid txb:bl u.txbu.poym)) :- ?. tx-match - ((slog leaf+"txid didn't match txid in wallet") ~) + %- (slog leaf+"txid didn't match txid in wallet") + [(give-update %error %broadcast-fail)]~ ~[(poke-provider [%broadcast-tx signed])] ?. tx-match state ?~ txbu.poym state @@ -486,7 +487,7 @@ =+ fee=~(fee txb:bl u.txbu.poym) ~& >> "{} vbytes, {<(div fee vb)>} sats/byte, {} sats fee" %- (slog [%leaf "PSBT: {}"]~) - [(give-update [%psbt u.pb])]~ + [(give-update [%psbt u.pb fee])]~ :: update outgoing payment with a rawtx, if the txid is in poym's txis :: ++ update-poym-txis @@ -629,12 +630,14 @@ %fail-broadcast-tx ?> =(src.bowl our.bowl) ~& >>> "%fail-broadcast-tx" - `state(poym [~ ~]) + :_ state(poym [~ ~]) + [(give-update %error %broadcast-fail)]~ :: %succeed-broadcast-tx ?> =(src.bowl our.bowl) ~& > "%succeed-broadcast-tx" :_ state + :- (give-update %broadcast-success ~) ?~ prov ~ :- (poke-provider [%tx-info txid.intr]) ?~ txbu.poym ~ diff --git a/pkg/arvo/lib/bitcoin-json.hoon b/pkg/arvo/lib/bitcoin-json.hoon index 665a5cfc9c..fb2562932b 100644 --- a/pkg/arvo/lib/bitcoin-json.hoon +++ b/pkg/arvo/lib/bitcoin-json.hoon @@ -104,13 +104,14 @@ %initial (initial upd) %change-provider (change-provider upd) %change-wallet (change-wallet upd) - %psbt s+pb.upd + %psbt (psbt upd) %btc-state (btc-state btc-state.upd) %new-tx (hest hest.upd) %cancel-tx (hexb txid.upd) %new-address (address address.upd) %balance (balance balance.upd) %error s+error.upd + %broadcast-success ~ == :: ++ initial @@ -142,6 +143,15 @@ history+(history history.upd) == :: + ++ psbt + |= upd=update:btc-wallet + ?> ?=(%psbt -.upd) + ^- json + %- pairs + :~ pb+s+pb.upd + fee+(numb fee.upd) + == + :: ++ balance |= b=(unit [p=@ q=@]) ^- json diff --git a/pkg/arvo/sur/btc-wallet.hoon b/pkg/arvo/sur/btc-wallet.hoon index 844d9f14d0..900a61e359 100644 --- a/pkg/arvo/sur/btc-wallet.hoon +++ b/pkg/arvo/sur/btc-wallet.hoon @@ -124,6 +124,7 @@ %no-dust %tx-being-signed %insufficient-balance + %broadcast-fail == :: data to send to the frontend :: @@ -136,9 +137,10 @@ =btc-state address=(unit address) == + [%broadcast-success ~] [%change-provider provider=(unit provider)] [%change-wallet wallet=(unit xpub) balance=(unit [p=sats q=sats]) =history] - [%psbt pb=@t] + [%psbt pb=@t fee=sats] [%btc-state =btc-state] [%new-tx =hest] [%cancel-tx =txid] diff --git a/pkg/btc-wallet/src/js/components/lib/balance.js b/pkg/btc-wallet/src/js/components/lib/balance.js index 4115647a28..a6e5fe7327 100644 --- a/pkg/btc-wallet/src/js/components/lib/balance.js +++ b/pkg/btc-wallet/src/js/components/lib/balance.js @@ -68,6 +68,7 @@ export default class Balance extends Component { <> {this.state.sending ? { this.setState({sending: false}); - store.handleEvent({data: {psbt: '', error: ''}}); + store.handleEvent({data: {psbt: '', fee: 0, error: '', "broadcast-fail": null}}); }} /> : this.setState({sent: true})); + this.broadCastTx(hex) + this.setState({broadcasting: true}); } catch(e) { - this.setState({error: true}); + this.setState({error: 'invalid-signed', broadcasting: false}); } } checkTxHex(e){ let txHex = e.target.value; let ready = (txHex.length > 0); - let error = false; + let error = ''; this.setState({txHex, ready, error}); } render() { const { stopSending, payee, denomination, satsAmount, psbt, currencyRates } = this.props; - const { sent, error, txHex } = this.state; + const { error, txHex } = this.state; let inputColor = 'black'; let inputBg = 'white'; let inputBorder = 'lightGray'; - if (error) { + if (error !== '') { inputColor = 'red'; inputBg = 'veryLightRed'; inputBorder = 'red'; } + console.log('bridge invoice', error); + return ( <> - { sent ? + { this.props.state.broadcastSuccess ? - {error && + { (error !== '') && - - Invalid signed bitcoin transaction - + mt={2}/> }