multi: update btcsuite API's to latest upstream changes

This commit makes a large number of minor changes concerning API usage
within the deamon to match the latest version on the upstream btcsuite
libraries.

The major changes are the switch from wire.ShaHash to chainhash.Hash,
and that wire.NewMsgTx() now takes a paramter indicating the version of
the transaction to be created.
This commit is contained in:
Olaoluwa Osuntokun committed 2017-01-05 13:56:34 -08:00
1 parent 5d37c1d9e7
commit 5affed38fc
40 files changed
+234 -211

No files matched your search

+6 -5
View File
@@ -5,6 +5,7 @@ import (
"errors"
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/roasbeef/btcd/chaincfg/chainhash"
"github.com/roasbeef/btcd/wire"
)
@@ -18,14 +19,14 @@ var (
// within the main chain.
//
// This method is a part of the lnwallet.BlockChainIO interface.
func (b *BtcWallet) GetBestBlock() (*wire.ShaHash, int32, error) {
func (b *BtcWallet) GetBestBlock() (*chainhash.Hash, int32, error) {
return b.rpc.GetBestBlock()
}
// GetTxOut returns the original output referenced by the passed outpoint.
//
// This method is a part of the lnwallet.BlockChainIO interface.
func (b *BtcWallet) GetUtxo(txid *wire.ShaHash, index uint32) (*wire.TxOut, error) {
func (b *BtcWallet) GetUtxo(txid *chainhash.Hash, index uint32) (*wire.TxOut, error) {
txout, err := b.rpc.GetTxOut(txid, index, false)
if err != nil {
return nil, err
@@ -50,7 +51,7 @@ func (b *BtcWallet) GetUtxo(txid *wire.ShaHash, index uint32) (*wire.TxOut, erro
// transaction ID.
//
// This method is a part of the lnwallet.BlockChainIO interface.
func (b *BtcWallet) GetTransaction(txid *wire.ShaHash) (*wire.MsgTx, error) {
func (b *BtcWallet) GetTransaction(txid *chainhash.Hash) (*wire.MsgTx, error) {
tx, err := b.rpc.GetRawTransaction(txid)
if err != nil {
return nil, err
@@ -62,7 +63,7 @@ func (b *BtcWallet) GetTransaction(txid *wire.ShaHash) (*wire.MsgTx, error) {
// GetBlock returns a raw block from the server given its hash.
//
// This method is a part of the lnwallet.BlockChainIO interface.
func (b *BtcWallet) GetBlock(blockHash *wire.ShaHash) (*wire.MsgBlock, error) {
func (b *BtcWallet) GetBlock(blockHash *chainhash.Hash) (*wire.MsgBlock, error) {
block, err := b.rpc.GetBlock(blockHash)
if err != nil {
return nil, err
@@ -75,7 +76,7 @@ func (b *BtcWallet) GetBlock(blockHash *wire.ShaHash) (*wire.MsgBlock, error) {
// given height.
//
// This method is a part of the lnwallet.BlockChainIO interface.
func (b *BtcWallet) GetBlockHash(blockHeight int64) (*wire.ShaHash, error) {
func (b *BtcWallet) GetBlockHash(blockHeight int64) (*chainhash.Hash, error) {
blockHash, err := b.rpc.GetBlockHash(blockHeight)
if err != nil {
return nil, err
+4 -3
View File
@@ -11,6 +11,7 @@ import (
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/roasbeef/btcd/btcec"
"github.com/roasbeef/btcd/chaincfg"
"github.com/roasbeef/btcd/chaincfg/chainhash"
"github.com/roasbeef/btcd/txscript"
"github.com/roasbeef/btcd/wire"
"github.com/roasbeef/btcutil"
@@ -308,7 +309,7 @@ func (b *BtcWallet) FetchRootKey() (*btcec.PrivateKey, error) {
// outputs are non-standard, a non-nil error will be be returned.
//
// This is a part of the WalletController interface.
func (b *BtcWallet) SendOutputs(outputs []*wire.TxOut) (*wire.ShaHash, error) {
func (b *BtcWallet) SendOutputs(outputs []*wire.TxOut) (*chainhash.Hash, error) {
return b.wallet.SendOutputs(outputs, defaultAccount, 1)
}
@@ -355,7 +356,7 @@ func (b *BtcWallet) ListUnspentWitness(minConfs int32) ([]*lnwallet.Utxo, error)
// the wallet are nested p2sh...
if txscript.IsPayToWitnessPubKeyHash(pkScript) ||
txscript.IsPayToScriptHash(pkScript) {
txid, err := wire.NewShaHashFromStr(output.TxID)
txid, err := chainhash.NewHashFromStr(output.TxID)
if err != nil {
return nil, err
}
@@ -384,7 +385,7 @@ func (b *BtcWallet) PublishTransaction(tx *wire.MsgTx) error {
// extractBalanceDelta extracts the net balance delta from the PoV of the
// wallet given a TransactionSummary.
func extractBalanceDelta(txSummary base.TransactionSummary) (btcutil.Amount, error) {
tx := wire.NewMsgTx()
tx := wire.NewMsgTx(1)
txReader := bytes.NewReader(txSummary.Transaction)
if err := tx.Deserialize(txReader); err != nil {
return -1, nil
+9 -9
View File
@@ -11,6 +11,7 @@ import (
"github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/roasbeef/btcd/chaincfg/chainhash"
"github.com/roasbeef/btcd/btcec"
"github.com/roasbeef/btcd/txscript"
@@ -19,7 +20,7 @@ import (
"github.com/roasbeef/btcutil/txsort"
)
var zeroHash wire.ShaHash
var zeroHash chainhash.Hash
var (
ErrChanClosing = fmt.Errorf("channel is being closed, operation disallowed")
@@ -584,7 +585,7 @@ type BreachRetribution struct {
func newBreachRetribution(chanState *channeldb.OpenChannel, stateNum uint64,
broadcastCommitment *wire.MsgTx) (*BreachRetribution, error) {
commitHash := broadcastCommitment.TxSha()
commitHash := broadcastCommitment.TxHash()
// Query the on-disk revocation log for the snapshot which was recorded
// at this particular state num.
@@ -1408,7 +1409,7 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.CommitRevocation) (
ourCommitKey := lc.channelState.OurCommitKey
currentRevocationKey := lc.channelState.TheirCurrentRevocation
pendingRevocation := wire.ShaHash(revMsg.Revocation)
pendingRevocation := chainhash.Hash(revMsg.Revocation)
// Ensure the new pre-image fits in properly within the elkrem receiver
// tree. If this fails, then all other checks are skipped.
@@ -1929,7 +1930,7 @@ func (lc *LightningChannel) ForceClose() (*ForceCloseSummary, error) {
return &ForceCloseSummary{
CloseTx: commitTx,
SelfOutpoint: wire.OutPoint{
Hash: commitTx.TxSha(),
Hash: commitTx.TxHash(),
Index: delayIndex,
},
SelfOutputMaturity: csvTimeout,
@@ -1951,7 +1952,7 @@ func (lc *LightningChannel) ForceClose() (*ForceCloseSummary, error) {
//
// TODO(roasbeef): caller should initiate signal to reject all incoming HTLCs,
// settle any inflight.
func (lc *LightningChannel) InitCooperativeClose() ([]byte, *wire.ShaHash, error) {
func (lc *LightningChannel) InitCooperativeClose() ([]byte, *chainhash.Hash, error) {
lc.Lock()
defer lc.Unlock()
@@ -1969,7 +1970,7 @@ func (lc *LightningChannel) InitCooperativeClose() ([]byte, *wire.ShaHash, error
lc.channelState.OurBalance, lc.channelState.TheirBalance,
lc.channelState.OurDeliveryScript, lc.channelState.TheirDeliveryScript,
lc.channelState.IsInitiator)
closeTxSha := closeTx.TxSha()
closeTxSha := closeTx.TxHash()
// Finally, sign the completed cooperative closure transaction. As the
// initiator we'll simply send our signature over the the remote party,
@@ -2095,8 +2096,7 @@ func CreateCommitTx(fundingOutput *wire.TxIn, selfKey, theirKey *btcec.PublicKey
// Now that both output scripts have been created, we can finally create
// the transaction itself. We use a transaction version of 2 since CSV
// will fail unless the tx version is >= 2.
commitTx := wire.NewMsgTx()
commitTx.Version = 2
commitTx := wire.NewMsgTx(2)
commitTx.AddTxIn(fundingOutput)
// Avoid creating zero value outputs within the commitment transaction.
@@ -2125,7 +2125,7 @@ func CreateCooperativeCloseTx(fundingTxIn *wire.TxIn,
// channel. In the event that one side doesn't have any settled funds
// within the channel then a refund output for that particular side can
// be omitted.
closeTx := wire.NewMsgTx()
closeTx := wire.NewMsgTx(2)
closeTx.AddTxIn(fundingTxIn)
// The initiator the a cooperative closure pays the fee in entirety.
+6 -5
View File
@@ -16,6 +16,7 @@ import (
"github.com/lightningnetwork/lnd/lnwire"
"github.com/roasbeef/btcd/blockchain"
"github.com/roasbeef/btcd/btcec"
"github.com/roasbeef/btcd/chaincfg/chainhash"
"github.com/roasbeef/btcd/txscript"
"github.com/roasbeef/btcd/wire"
"github.com/roasbeef/btcutil"
@@ -87,7 +88,7 @@ func (m *mockSigner) ComputeInputScript(tx *wire.MsgTx, signDesc *SignDescriptor
type mockNotfier struct {
}
func (m *mockNotfier) RegisterConfirmationsNtfn(txid *wire.ShaHash, numConfs uint32) (*chainntnfs.ConfirmationEvent, error) {
func (m *mockNotfier) RegisterConfirmationsNtfn(txid *chainhash.Hash, numConfs uint32) (*chainntnfs.ConfirmationEvent, error) {
return nil, nil
}
func (m *mockNotfier) RegisterBlockEpochNtfn() (*chainntnfs.BlockEpochEvent, error) {
@@ -199,7 +200,7 @@ func createTestChannels(revocationWindow int) (*LightningChannel, *LightningChan
}
prevOut := &wire.OutPoint{
Hash: wire.ShaHash(testHdSeed),
Hash: chainhash.Hash(testHdSeed),
Index: 0,
}
fundingTxIn := wire.NewTxIn(prevOut, nil, nil)
@@ -614,7 +615,7 @@ func TestCheckCommitTxSize(t *testing.T) {
t.Fatalf("unable to initiate alice force close: %v", err)
}
actualCost := blockchain.GetMsgTxCost(commitTx)
actualCost := blockchain.GetTransactionWeight(btcutil.NewTx(commitTx))
estimatedCost := estimateCommitTxCost(count, false)
diff := int(estimatedCost - actualCost)
@@ -709,7 +710,7 @@ func TestCooperativeChannelClosure(t *testing.T) {
if err != nil {
t.Fatalf("unable to complete alice cooperative close: %v", err)
}
bobCloseSha := closeTx.TxSha()
bobCloseSha := closeTx.TxHash()
if !bobCloseSha.IsEqual(txid) {
t.Fatalf("alice's transactions doesn't match: %x vs %x",
bobCloseSha[:], txid[:])
@@ -729,7 +730,7 @@ func TestCooperativeChannelClosure(t *testing.T) {
if err != nil {
t.Fatalf("unable to complete bob cooperative close: %v", err)
}
aliceCloseSha := closeTx.TxSha()
aliceCloseSha := closeTx.TxHash()
if !aliceCloseSha.IsEqual(txid) {
t.Fatalf("bob's closure transactions don't match: %x vs %x",
aliceCloseSha[:], txid[:])
+9 -8
View File
@@ -6,6 +6,7 @@ import (
"sync"
"github.com/roasbeef/btcd/btcec"
"github.com/roasbeef/btcd/chaincfg/chainhash"
"github.com/roasbeef/btcd/txscript"
"github.com/roasbeef/btcd/wire"
"github.com/roasbeef/btcutil"
@@ -42,7 +43,7 @@ type Utxo struct {
// the wallet, or has outputs that pay to the wallet.
type TransactionDetail struct {
// Hash is the transaction hash of the transaction.
Hash wire.ShaHash
Hash chainhash.Hash
// Value is the net value of this transaction (in satoshis) from the
// PoV of the wallet. If this transaction purely spends from the
@@ -58,7 +59,7 @@ type TransactionDetail struct {
// BlockHeight is the hash of the block which includes this
// transaction. Unconfirmed transactions will have a nil value for this
// field.
BlockHash *wire.ShaHash
BlockHash *chainhash.Hash
// BlockHeight is the height of the block including this transaction.
// Unconfirmed transaction will show a height of zero.
@@ -142,7 +143,7 @@ type WalletController interface {
// paying out to the specified outputs. In the case the wallet has
// insufficient funds, or the outputs are non-standard, an error
// should be returned.
SendOutputs(outputs []*wire.TxOut) (*wire.ShaHash, error)
SendOutputs(outputs []*wire.TxOut) (*chainhash.Hash, error)
// ListUnspentWitness returns all unspent outputs which are version 0
// witness programs. The 'confirms' parameter indicates the minimum
@@ -203,23 +204,23 @@ type WalletController interface {
type BlockChainIO interface {
// GetBestBlock returns the current height and block hash of the valid
// most-work chain the implementation is aware of.
GetBestBlock() (*wire.ShaHash, int32, error)
GetBestBlock() (*chainhash.Hash, int32, error)
// GetTxOut returns the original output referenced by the passed
// outpoint.
GetUtxo(txid *wire.ShaHash, index uint32) (*wire.TxOut, error)
GetUtxo(txid *chainhash.Hash, index uint32) (*wire.TxOut, error)
// GetTransaction returns the full transaction identified by the passed
// transaction ID.
GetTransaction(txid *wire.ShaHash) (*wire.MsgTx, error)
GetTransaction(txid *chainhash.Hash) (*wire.MsgTx, error)
// GetBlockHash returns the hash of the block in the best block chain
// at the given height.
GetBlockHash(blockHeight int64) (*wire.ShaHash, error)
GetBlockHash(blockHeight int64) (*chainhash.Hash, error)
// GetBlock returns the block in the main chain identified by the given
// hash.
GetBlock(blockHash *wire.ShaHash) (*wire.MsgBlock, error)
GetBlock(blockHash *chainhash.Hash) (*wire.MsgBlock, error)
}
// SignDescriptor houses the necessary information required to successfully sign
+13 -12
View File
@@ -18,6 +18,7 @@ import (
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwallet/btcwallet"
"github.com/roasbeef/btcd/chaincfg"
"github.com/roasbeef/btcd/chaincfg/chainhash"
"github.com/roasbeef/btcutil/txsort"
_ "github.com/roasbeef/btcwallet/walletdb/bdb"
@@ -209,7 +210,7 @@ func newBobNode(miner *rpctest.Harness, amt btcutil.Amount) (*bobNode, error) {
// Give bobNode one 7 BTC output for use in creating channels.
output := &wire.TxOut{7e8, bobAddrScript}
mainTxid, err := miner.CoinbaseSpend([]*wire.TxOut{output})
mainTxid, err := miner.SendOutputs([]*wire.TxOut{output}, 10)
if err != nil {
return nil, err
}
@@ -247,7 +248,7 @@ func newBobNode(miner *rpctest.Harness, amt btcutil.Amount) (*bobNode, error) {
copy(obsfucator[:], revocation[:])
// His ID is just as creative...
var id [wire.HashSize]byte
var id [chainhash.HashSize]byte
id[0] = 0xff
return &bobNode{
@@ -283,7 +284,7 @@ func loadTestCredits(miner *rpctest.Harness, w *lnwallet.LightningWallet, numOut
addrs = append(addrs, walletAddr)
output := &wire.TxOut{satoshiPerOutput, script}
if _, err := miner.CoinbaseSpend([]*wire.TxOut{output}); err != nil {
if _, err := miner.SendOutputs([]*wire.TxOut{output}, 10); err != nil {
return err
}
}
@@ -466,7 +467,7 @@ func testDualFundingReservationWorkflow(miner *rpctest.Harness, wallet *lnwallet
// txn hits a "comfortable" depth.
// The resulting active channel state should have been persisted to the DB.
fundingSha := fundingTx.TxSha()
fundingSha := fundingTx.TxHash()
channels, err := wallet.ChannelDB.FetchOpenChannels(bobNode.id)
if err != nil {
t.Fatalf("unable to retrieve channel from DB: %v", err)
@@ -732,7 +733,7 @@ func testSingleFunderReservationWorkflowInitiator(miner *rpctest.Harness,
// The resulting active channel state should have been persisted to the DB.
// TODO(roasbeef): de-duplicate
fundingTx := chanReservation.FinalFundingTx()
fundingSha := fundingTx.TxSha()
fundingSha := fundingTx.TxHash()
channels, err := wallet.ChannelDB.FetchOpenChannels(bobNode.id)
if err != nil {
t.Fatalf("unable to retrieve channel from DB: %v", err)
@@ -854,7 +855,7 @@ func testSingleFunderReservationWorkflowResponder(miner *rpctest.Harness,
// At this point, we send Bob our contribution, allowing him to
// construct the funding transaction, and sign our version of the
// commitment transaction.
fundingTx := wire.NewMsgTx()
fundingTx := wire.NewMsgTx(1)
fundingTx.AddTxIn(bobNode.availableOutputs[0])
fundingTx.AddTxOut(bobNode.changeOutputs[0])
fundingTx.AddTxOut(multiOut)
@@ -866,7 +867,7 @@ func testSingleFunderReservationWorkflowResponder(miner *rpctest.Harness,
// Locate the output index of the 2-of-2 in order to send back to the
// wallet so it can finalize the transaction by signing bob's commitment
// transaction.
fundingTxID := fundingTx.TxSha()
fundingTxID := fundingTx.TxHash()
_, multiSigIndex := lnwallet.FindScriptOutputIndex(fundingTx, multiOut.PkScript)
fundingOutpoint := wire.NewOutPoint(&fundingTxID, multiSigIndex)
bobObsfucator := bobNode.obsfucator
@@ -923,7 +924,7 @@ func testListTransactionDetails(miner *rpctest.Harness, wallet *lnwallet.Lightni
// Create 5 new outputs spendable by the wallet.
const numTxns = 5
const outputAmt = btcutil.SatoshiPerBitcoin
txids := make(map[wire.ShaHash]struct{})
txids := make(map[chainhash.Hash]struct{})
for i := 0; i < numTxns; i++ {
addr, err := wallet.NewAddress(lnwallet.WitnessPubKey, false)
if err != nil {
@@ -935,7 +936,7 @@ func testListTransactionDetails(miner *rpctest.Harness, wallet *lnwallet.Lightni
}
output := &wire.TxOut{outputAmt, script}
txid, err := miner.CoinbaseSpend([]*wire.TxOut{output})
txid, err := miner.SendOutputs([]*wire.TxOut{output}, 10)
if err != nil {
t.Fatalf("unable to send coinbase: %v", err)
}
@@ -1083,7 +1084,7 @@ func testTransactionSubscriptions(miner *rpctest.Harness, w *lnwallet.LightningW
}
output := &wire.TxOut{outputAmt, script}
if _, err := miner.CoinbaseSpend([]*wire.TxOut{output}); err != nil {
if _, err := miner.SendOutputs([]*wire.TxOut{output}, 10); err != nil {
t.Fatalf("unable to send coinbase: %v", err)
}
}
@@ -1183,10 +1184,10 @@ func testSignOutputPrivateTweak(r *rpctest.Harness, w *lnwallet.LightningWallet,
/// WIth the index located, we can create a transaction spending the
//referenced output.
sweepTx := wire.NewMsgTx()
sweepTx := wire.NewMsgTx(2)
sweepTx.AddTxIn(&wire.TxIn{
PreviousOutPoint: wire.OutPoint{
Hash: tx.TxSha(),
Hash: tx.TxHash(),
Index: outputIndex,
},
})
+3 -2
View File
@@ -11,6 +11,7 @@ import (
"github.com/btcsuite/fastsha256"
"github.com/roasbeef/btcd/btcec"
"github.com/roasbeef/btcd/chaincfg/chainhash"
"github.com/roasbeef/btcd/txscript"
"github.com/roasbeef/btcd/wire"
"github.com/roasbeef/btcutil"
@@ -749,7 +750,7 @@ func DeriveRevocationPrivKey(commitPrivKey *btcec.PrivateKey,
// [2]: https://tools.ietf.org/html/rfc5869
func deriveElkremRoot(elkremDerivationRoot *btcec.PrivateKey,
localMultiSigKey *btcec.PublicKey,
remoteMultiSigKey *btcec.PublicKey) wire.ShaHash {
remoteMultiSigKey *btcec.PublicKey) chainhash.Hash {
secret := elkremDerivationRoot.Serialize()
salt := localMultiSigKey.SerializeCompressed()
@@ -760,7 +761,7 @@ func deriveElkremRoot(elkremDerivationRoot *btcec.PrivateKey,
// It's safe to ignore the error her as we know for sure that we won't
// be draining the HKDF past its available entropy horizon.
// TODO(roasbeef): revisit...
var elkremRoot wire.ShaHash
var elkremRoot chainhash.Hash
rootReader.Read(elkremRoot[:])
return elkremRoot
+9 -10
View File
@@ -67,9 +67,8 @@ func TestCommitmentSpendValidation(t *testing.T) {
if err != nil {
t.Fatalf("unable to create target output: %v")
}
sweepTx := wire.NewMsgTx()
sweepTx.Version = 2
sweepTx.AddTxIn(wire.NewTxIn(&wire.OutPoint{commitmentTx.TxSha(), 0}, nil, nil))
sweepTx := wire.NewMsgTx(2)
sweepTx.AddTxIn(wire.NewTxIn(&wire.OutPoint{commitmentTx.TxHash(), 0}, nil, nil))
sweepTx.AddTxOut(&wire.TxOut{
PkScript: targetOutput,
Value: 0.5 * 10e8,
@@ -267,7 +266,7 @@ func TestHTLCSenderSpendValidation(t *testing.T) {
// This will be Alice's commitment transaction. In this scenario Alice
// is sending an HTLC to a node she has a a path to (could be Bob,
// could be multiple hops down, it doesn't really matter).
senderCommitTx := wire.NewMsgTx()
senderCommitTx := wire.NewMsgTx(2)
senderCommitTx.AddTxIn(fakeFundingTxIn)
senderCommitTx.AddTxOut(&wire.TxOut{
Value: int64(paymentAmt),
@@ -275,11 +274,11 @@ func TestHTLCSenderSpendValidation(t *testing.T) {
})
prevOut := &wire.OutPoint{
Hash: senderCommitTx.TxSha(),
Hash: senderCommitTx.TxHash(),
Index: 0,
}
sweepTx := wire.NewMsgTx()
sweepTx := wire.NewMsgTx(2)
sweepTx.AddTxIn(wire.NewTxIn(prevOut, nil, nil))
sweepTx.AddTxOut(
&wire.TxOut{
@@ -439,7 +438,7 @@ func TestHTLCReceiverSpendValidation(t *testing.T) {
// This will be Bob's commitment transaction. In this scenario Alice
// is sending an HTLC to a node she has a a path to (could be Bob,
// could be multiple hops down, it doesn't really matter).
recieverCommitTx := wire.NewMsgTx()
recieverCommitTx := wire.NewMsgTx(2)
recieverCommitTx.AddTxIn(fakeFundingTxIn)
recieverCommitTx.AddTxOut(&wire.TxOut{
Value: int64(paymentAmt),
@@ -447,11 +446,11 @@ func TestHTLCReceiverSpendValidation(t *testing.T) {
})
prevOut := &wire.OutPoint{
Hash: recieverCommitTx.TxSha(),
Hash: recieverCommitTx.TxHash(),
Index: 0,
}
sweepTx := wire.NewMsgTx()
sweepTx := wire.NewMsgTx(2)
sweepTx.AddTxIn(wire.NewTxIn(prevOut, nil, nil))
sweepTx.AddTxOut(
&wire.TxOut{
@@ -559,7 +558,7 @@ func TestHTLCReceiverSpendValidation(t *testing.T) {
}
func TestCommitTxStateHint(t *testing.T) {
commitTx := wire.NewMsgTx()
commitTx := wire.NewMsgTx(2)
commitTx.AddTxIn(&wire.TxIn{})
var obsfucator [StateHintSize]byte
+1 -1
View File
@@ -6,7 +6,7 @@ import (
const (
WitnessFactor = blockchain.WitnessScaleFactor
MaxTransactionWeightPolicy = blockchain.MaxBlockCost / 10
MaxTransactionWeightPolicy = blockchain.MaxBlockWeight / 10
// The weight(cost), which is different from the !size! (see BIP-141),
// is calculated as:
+3 -3
View File
@@ -661,7 +661,7 @@ func (l *LightningWallet) handleContributionMsg(req *addContributionMsg) {
// Create a blank, fresh transaction. Soon to be a complete funding
// transaction which will allow opening a lightning channel.
pendingReservation.fundingTx = wire.NewMsgTx()
pendingReservation.fundingTx = wire.NewMsgTx(1)
fundingTx := pendingReservation.fundingTx
// Some temporary variables to cut down on the resolution verbosity.
@@ -739,7 +739,7 @@ func (l *LightningWallet) handleContributionMsg(req *addContributionMsg) {
// Locate the index of the multi-sig outpoint in order to record it
// since the outputs are canonically sorted. If this is a single funder
// workflow, then we'll also need to send this to the remote node.
fundingTxID := fundingTx.TxSha()
fundingTxID := fundingTx.TxHash()
_, multiSigIndex := FindScriptOutputIndex(fundingTx, multiSigOut.PkScript)
fundingOutpoint := wire.NewOutPoint(&fundingTxID, multiSigIndex)
pendingReservation.partialState.FundingOutpoint = fundingOutpoint
@@ -1235,7 +1235,7 @@ func (l *LightningWallet) handleChannelOpen(req *channelOpenMsg) {
func (l *LightningWallet) openChannelAfterConfirmations(res *ChannelReservation) {
// Register with the ChainNotifier for a notification once the funding
// transaction reaches `numConfs` confirmations.
txid := res.fundingTx.TxSha()
txid := res.fundingTx.TxHash()
numConfs := uint32(res.numConfsToOpen)
confNtfn, _ := l.chainNotifier.RegisterConfirmationsNtfn(&txid, numConfs)