Merge pull request #568 from joostjager/output-indices

wallet: return full tx from SendOutputs
This commit is contained in:
Olaoluwa Osuntokun 2018-11-07 16:38:07 +11:00 committed by GitHub
commit 6d43b2e29b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 5 deletions

View file

@ -1378,7 +1378,7 @@ func sendPairs(w *wallet.Wallet, amounts map[string]btcutil.Amount,
if err != nil {
return "", err
}
txHash, err := w.SendOutputs(outputs, account, minconf, feeSatPerKb)
tx, err := w.SendOutputs(outputs, account, minconf, feeSatPerKb)
if err != nil {
if err == txrules.ErrAmountNegative {
return "", ErrNeedPositiveAmount
@ -1397,7 +1397,7 @@ func sendPairs(w *wallet.Wallet, amounts map[string]btcutil.Amount,
}
}
txHashStr := txHash.String()
txHashStr := tx.TxHash().String()
log.Infof("Successfully sent transaction %v", txHashStr)
return txHashStr, nil
}

View file

@ -3087,9 +3087,9 @@ func (w *Wallet) TotalReceivedForAddr(addr btcutil.Address, minConf int32) (btcu
}
// SendOutputs creates and sends payment transactions. It returns the
// transaction hash upon success.
// transaction upon success.
func (w *Wallet) SendOutputs(outputs []*wire.TxOut, account uint32,
minconf int32, satPerKb btcutil.Amount) (*chainhash.Hash, error) {
minconf int32, satPerKb btcutil.Amount) (*wire.MsgTx, error) {
// Ensure the outputs to be created adhere to the network's consensus
// rules.
@ -3108,7 +3108,17 @@ func (w *Wallet) SendOutputs(outputs []*wire.TxOut, account uint32,
return nil, err
}
return w.publishTransaction(createdTx.Tx)
txHash, err := w.publishTransaction(createdTx.Tx)
if err != nil {
return nil, err
}
// Sanity check on the returned tx hash.
if *txHash != createdTx.Tx.TxHash() {
return nil, errors.New("tx hash mismatch")
}
return createdTx.Tx, nil
}
// SignatureError records the underlying error when validating a transaction