From c164dbee82438caeccb9bdac141d85d1ef7e61f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Mon, 10 Sep 2018 17:48:31 +0200 Subject: [PATCH] use libcore inputs and outputs to return the optimistic update --- src/commands/libcoreSignAndBroadcast.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/commands/libcoreSignAndBroadcast.js b/src/commands/libcoreSignAndBroadcast.js index e479c9f3..83d36a2b 100644 --- a/src/commands/libcoreSignAndBroadcast.js +++ b/src/commands/libcoreSignAndBroadcast.js @@ -164,7 +164,6 @@ export async function doSignAndBroadcast({ accountId, currencyId, xpub, - freshAddress, freshAddressPath, index, transaction, @@ -237,6 +236,16 @@ export async function doSignAndBroadcast({ .asBitcoinLikeAccount() .broadcastRawTransaction(Array.from(Buffer.from(signedTransaction, 'hex'))) + const senders = builded + .getInputs() + .map(input => input.getAddress()) + .filter(a => a) + + const recipients = builded + .getOutputs() + .map(output => output.getAddress()) + .filter(a => a) + const fee = libcoreAmountToBigNumber(builded.getFees()) // NB we don't check isCancelled() because the broadcast is not cancellable now! @@ -250,9 +259,8 @@ export async function doSignAndBroadcast({ fee: fee.toString(), blockHash: null, blockHeight: null, - // FIXME for senders and recipients, can we ask the libcore? - senders: [freshAddress], - recipients: [transaction.recipient], + senders, + recipients, accountId, date: new Date().toISOString(), })