Merge pull request #2155 from joostjager/return-tx
lnwallet: update to new SendOutputs signature
This commit is contained in:
commit
776059bdab
5
Gopkg.lock
generated
5
Gopkg.lock
generated
@ -106,7 +106,7 @@
|
||||
revision = "ab6388e0c60ae4834a1f57511e20c17b5f78be4b"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:ac01796bf202b80d6cb1b92d42df0fbbf3aff964451376bfa7c39bc2bf94d108"
|
||||
digest = "1:2995aa2bcb95d13a8df309e1dcb6ac20786acb90df5a090bf5e07c2086219ce8"
|
||||
name = "github.com/btcsuite/btcwallet"
|
||||
packages = [
|
||||
"chain",
|
||||
@ -123,10 +123,11 @@
|
||||
"wallet/txrules",
|
||||
"walletdb",
|
||||
"walletdb/bdb",
|
||||
"walletdb/migration",
|
||||
"wtxmgr",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "c4dd27e481f9801866cf5226bfe532084772ec2a"
|
||||
revision = "6d43b2e29b5eef0f000a301ee6fbd146db75d118"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
|
@ -72,7 +72,7 @@
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/btcsuite/btcwallet"
|
||||
revision = "c4dd27e481f9801866cf5226bfe532084772ec2a"
|
||||
revision = "6d43b2e29b5eef0f000a301ee6fbd146db75d118"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/tv42/zbase32"
|
||||
|
@ -268,7 +268,7 @@ func (b *BtcWallet) IsOurAddress(a btcutil.Address) bool {
|
||||
//
|
||||
// This is a part of the WalletController interface.
|
||||
func (b *BtcWallet) SendOutputs(outputs []*wire.TxOut,
|
||||
feeRate lnwallet.SatPerKWeight) (*chainhash.Hash, error) {
|
||||
feeRate lnwallet.SatPerKWeight) (*wire.MsgTx, error) {
|
||||
|
||||
// Convert our fee rate from sat/kw to sat/kb since it's required by
|
||||
// SendOutputs.
|
||||
|
@ -157,7 +157,7 @@ type WalletController interface {
|
||||
// This method also takes the target fee expressed in sat/kw that should
|
||||
// be used when crafting the transaction.
|
||||
SendOutputs(outputs []*wire.TxOut,
|
||||
feeRate SatPerKWeight) (*chainhash.Hash, error)
|
||||
feeRate SatPerKWeight) (*wire.MsgTx, error)
|
||||
|
||||
// ListUnspentWitness returns all unspent outputs which are version 0
|
||||
// witness programs. The 'minconfirms' and 'maxconfirms' parameters
|
||||
|
@ -1069,11 +1069,12 @@ func testListTransactionDetails(miner *rpctest.Harness,
|
||||
t.Fatalf("unable to make output script: %v", err)
|
||||
}
|
||||
burnOutput := wire.NewTxOut(outputAmt, outputScript)
|
||||
burnTXID, err := alice.SendOutputs([]*wire.TxOut{burnOutput}, 2500)
|
||||
burnTX, err := alice.SendOutputs([]*wire.TxOut{burnOutput}, 2500)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create burn tx: %v", err)
|
||||
}
|
||||
err = waitForMempoolTx(miner, burnTXID)
|
||||
burnTXID := burnTX.TxHash()
|
||||
err = waitForMempoolTx(miner, &burnTXID)
|
||||
if err != nil {
|
||||
t.Fatalf("tx not relayed to miner: %v", err)
|
||||
}
|
||||
@ -1281,11 +1282,12 @@ func testTransactionSubscriptions(miner *rpctest.Harness,
|
||||
t.Fatalf("unable to make output script: %v", err)
|
||||
}
|
||||
burnOutput := wire.NewTxOut(outputAmt, outputScript)
|
||||
txid, err := alice.SendOutputs([]*wire.TxOut{burnOutput}, 2500)
|
||||
tx, err := alice.SendOutputs([]*wire.TxOut{burnOutput}, 2500)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create burn tx: %v", err)
|
||||
}
|
||||
err = waitForMempoolTx(miner, txid)
|
||||
txid := tx.TxHash()
|
||||
err = waitForMempoolTx(miner, &txid)
|
||||
if err != nil {
|
||||
t.Fatalf("tx not relayed to miner: %v", err)
|
||||
}
|
||||
@ -1304,7 +1306,7 @@ func testTransactionSubscriptions(miner *rpctest.Harness,
|
||||
case <-time.After(time.Second * 10):
|
||||
t.Fatalf("transactions not received after 10 seconds")
|
||||
case unConfTx := <-txClient.UnconfirmedTransactions():
|
||||
if unConfTx.Hash != *txid {
|
||||
if unConfTx.Hash != txid {
|
||||
t.Fatalf("wrong txn notified: expected %v got %v",
|
||||
txid, unConfTx.Hash)
|
||||
}
|
||||
@ -1457,27 +1459,24 @@ func testPublishTransaction(r *rpctest.Harness,
|
||||
Value: btcutil.SatoshiPerBitcoin,
|
||||
PkScript: keyScript,
|
||||
}
|
||||
txid, err := alice.SendOutputs([]*wire.TxOut{newOutput}, 2500)
|
||||
tx, err := alice.SendOutputs([]*wire.TxOut{newOutput}, 2500)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create output: %v", err)
|
||||
}
|
||||
txid := tx.TxHash()
|
||||
|
||||
// Query for the transaction generated above so we can located
|
||||
// the index of our output.
|
||||
err = waitForMempoolTx(r, txid)
|
||||
err = waitForMempoolTx(r, &txid)
|
||||
if err != nil {
|
||||
t.Fatalf("tx not relayed to miner: %v", err)
|
||||
}
|
||||
tx, err := r.Node.GetRawTransaction(txid)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to query for tx: %v", err)
|
||||
}
|
||||
|
||||
if err := mineAndAssert(tx.MsgTx()); err != nil {
|
||||
if err := mineAndAssert(tx); err != nil {
|
||||
t.Fatalf("unable to mine tx: %v", err)
|
||||
}
|
||||
txFee := btcutil.Amount(0.1 * btcutil.SatoshiPerBitcoin)
|
||||
tx1 := txFromOutput(tx.MsgTx(), pubKey.PubKey, txFee)
|
||||
tx1 := txFromOutput(tx, pubKey.PubKey, txFee)
|
||||
|
||||
return tx1
|
||||
}
|
||||
@ -1702,23 +1701,19 @@ func testSignOutputUsingTweaks(r *rpctest.Harness,
|
||||
Value: btcutil.SatoshiPerBitcoin,
|
||||
PkScript: keyScript,
|
||||
}
|
||||
txid, err := alice.SendOutputs([]*wire.TxOut{newOutput}, 2500)
|
||||
tx, err := alice.SendOutputs([]*wire.TxOut{newOutput}, 2500)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create output: %v", err)
|
||||
}
|
||||
|
||||
txid := tx.TxHash()
|
||||
// Query for the transaction generated above so we can located
|
||||
// the index of our output.
|
||||
err = waitForMempoolTx(r, txid)
|
||||
err = waitForMempoolTx(r, &txid)
|
||||
if err != nil {
|
||||
t.Fatalf("tx not relayed to miner: %v", err)
|
||||
}
|
||||
tx, err := r.Node.GetRawTransaction(txid)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to query for tx: %v", err)
|
||||
}
|
||||
var outputIndex uint32
|
||||
if bytes.Equal(tx.MsgTx().TxOut[0].PkScript, keyScript) {
|
||||
if bytes.Equal(tx.TxOut[0].PkScript, keyScript) {
|
||||
outputIndex = 0
|
||||
} else {
|
||||
outputIndex = 1
|
||||
@ -1729,7 +1724,7 @@ func testSignOutputUsingTweaks(r *rpctest.Harness,
|
||||
sweepTx := wire.NewMsgTx(2)
|
||||
sweepTx.AddTxIn(&wire.TxIn{
|
||||
PreviousOutPoint: wire.OutPoint{
|
||||
Hash: tx.MsgTx().TxHash(),
|
||||
Hash: txid,
|
||||
Index: outputIndex,
|
||||
},
|
||||
})
|
||||
@ -1828,11 +1823,12 @@ func testReorgWalletBalance(r *rpctest.Harness, w *lnwallet.LightningWallet,
|
||||
Value: 1e8,
|
||||
PkScript: script,
|
||||
}
|
||||
txid, err := w.SendOutputs([]*wire.TxOut{output}, 2500)
|
||||
tx, err := w.SendOutputs([]*wire.TxOut{output}, 2500)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to send outputs: %v", err)
|
||||
}
|
||||
err = waitForMempoolTx(r, txid)
|
||||
txid := tx.TxHash()
|
||||
err = waitForMempoolTx(r, &txid)
|
||||
if err != nil {
|
||||
t.Fatalf("tx not relayed to miner: %v", err)
|
||||
}
|
||||
|
2
mock.go
2
mock.go
@ -227,7 +227,7 @@ func (*mockWalletController) IsOurAddress(a btcutil.Address) bool {
|
||||
}
|
||||
|
||||
func (*mockWalletController) SendOutputs(outputs []*wire.TxOut,
|
||||
_ lnwallet.SatPerKWeight) (*chainhash.Hash, error) {
|
||||
_ lnwallet.SatPerKWeight) (*wire.MsgTx, error) {
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
@ -408,7 +408,13 @@ func (r *rpcServer) sendCoinsOnChain(paymentMap map[string]int64,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return r.server.cc.wallet.SendOutputs(outputs, feeRate)
|
||||
tx, err := r.server.cc.wallet.SendOutputs(outputs, feeRate)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
txHash := tx.TxHash()
|
||||
return &txHash, err
|
||||
}
|
||||
|
||||
// determineFeePerKw will determine the fee in sat/kw that should be paid given
|
||||
|
Loading…
Reference in New Issue
Block a user