lnwallet+routing: modify BlockChainIO.GetUtxo to be light client friendly
This commit modifies the GetUtxo method of the BlockChainIO interface to be more light client friendly by introducing a height hint which gives light clients that don’t have UTXO set commitments a way in which they can restrict their search space. Light clients will now be able to have a concrete cut off point in the chain as they scan backwards for spentness of an output.
This commit is contained in:
parent
333373f78f
commit
a18d9b8449
@ -26,8 +26,8 @@ func (b *BtcWallet) GetBestBlock() (*chainhash.Hash, int32, error) {
|
|||||||
// GetUtxo returns the original output referenced by the passed outpoint.
|
// GetUtxo returns the original output referenced by the passed outpoint.
|
||||||
//
|
//
|
||||||
// This method is a part of the lnwallet.BlockChainIO interface.
|
// This method is a part of the lnwallet.BlockChainIO interface.
|
||||||
func (b *BtcWallet) GetUtxo(txid *chainhash.Hash, index uint32) (*wire.TxOut, error) {
|
func (b *BtcWallet) GetUtxo(op *wire.OutPoint, _ uint32) (*wire.TxOut, error) {
|
||||||
txout, err := b.rpc.GetTxOut(txid, index, false)
|
txout, err := b.rpc.GetTxOut(&op.Hash, op.Index, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if txout == nil {
|
} else if txout == nil {
|
||||||
|
@ -209,9 +209,12 @@ type BlockChainIO interface {
|
|||||||
// most-work chain the implementation is aware of.
|
// most-work chain the implementation is aware of.
|
||||||
GetBestBlock() (*chainhash.Hash, int32, error)
|
GetBestBlock() (*chainhash.Hash, int32, error)
|
||||||
|
|
||||||
// GetTxOut returns the original output referenced by the passed
|
// GetUtxo attempts to return the passed outpoint if it's still a
|
||||||
// outpoint.
|
// member of the utxo set. The passed height hint should be the "birth
|
||||||
GetUtxo(txid *chainhash.Hash, index uint32) (*wire.TxOut, error)
|
// height" of the passed outpoint. In the case that the output is in
|
||||||
|
// the UTXO set, then the output corresponding to that output is
|
||||||
|
// returned. Otherwise, a non-nil error will be returned.
|
||||||
|
GetUtxo(op *wire.OutPoint, heightHint uint32) (*wire.TxOut, error)
|
||||||
|
|
||||||
// GetTransaction returns the full transaction identified by the passed
|
// GetTransaction returns the full transaction identified by the passed
|
||||||
// transaction ID.
|
// transaction ID.
|
||||||
|
@ -978,8 +978,8 @@ func (l *LightningWallet) handleFundingCounterPartySigs(msg *addCounterPartySigs
|
|||||||
|
|
||||||
// Fetch the alleged previous output along with the
|
// Fetch the alleged previous output along with the
|
||||||
// pkscript referenced by this input.
|
// pkscript referenced by this input.
|
||||||
prevOut := txin.PreviousOutPoint
|
// TODO(roasbeef): when dual funder pass actual height-hint
|
||||||
output, err := l.ChainIO.GetUtxo(&prevOut.Hash, prevOut.Index)
|
output, err := l.ChainIO.GetUtxo(&txin.PreviousOutPoint, 0)
|
||||||
if output == nil {
|
if output == nil {
|
||||||
msg.err <- fmt.Errorf("input to funding tx "+
|
msg.err <- fmt.Errorf("input to funding tx "+
|
||||||
"does not exist: %v", err)
|
"does not exist: %v", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user