Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lock outpoint on process feetx #1950

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Check if tx is unpublished on processTransactionRecord
vctt94 committed Dec 15, 2020
commit 92237458c40879670574289fe50bae2cc209d6ad
4 changes: 2 additions & 2 deletions internal/vsp/vsp.go
Original file line number Diff line number Diff line change
@@ -375,11 +375,11 @@ func (v *VSP) Process(ctx context.Context, ticketHash chainhash.Hash, credits []
}
// set fee tx as unpublished, because it will be published by the vsp.
feeHash := feeTx.TxHash()
err = v.cfg.Wallet.AddTransaction(ctx, feeTx, nil)
err = v.cfg.Wallet.SetPublished(ctx, &feeHash, false)
if err != nil {
return nil, err
}
err = v.cfg.Wallet.SetPublished(ctx, &feeHash, false)
err = v.cfg.Wallet.AddTransaction(ctx, feeTx, nil)
if err != nil {
return nil, err
}
9 changes: 7 additions & 2 deletions wallet/chainntfns.go
Original file line number Diff line number Diff line change
@@ -566,8 +566,13 @@ func (w *Wallet) processTransactionRecord(ctx context.Context, dbtx walletdb.Rea
}

// Skip unlocking outpoints if the transaction is a vote or revocation as the lock
// is not held.
skipOutpoints := rec.TxType == stake.TxTypeSSGen || rec.TxType == stake.TxTypeSSRtx
// is not held. Also if it is an unpublished tx.
var isUnpublished bool
err = walletdb.View(ctx, w.db, func(tx walletdb.ReadTx) error {
isUnpublished = w.txStore.ExistsUnpublished(tx, &rec.Hash)
return nil
})
skipOutpoints := rec.TxType == stake.TxTypeSSGen || rec.TxType == stake.TxTypeSSRtx || isUnpublished

// Handle input scripts that contain P2PKs that we care about.
for i, input := range rec.MsgTx.TxIn {
6 changes: 6 additions & 0 deletions wallet/udb/txunmined.go
Original file line number Diff line number Diff line change
@@ -141,6 +141,12 @@ func (s *Store) SetPublished(dbtx walletdb.ReadWriteTx, txHash *chainhash.Hash,
return putUnpublished(ns, txHash[:])
}

// ExistsUnpublished exported method of exists Unpublished
func (s *Store) ExistsUnpublished(dbtx walletdb.ReadTx, txHash *chainhash.Hash) bool {
ns := dbtx.ReadBucket(wtxmgrBucketKey)
return existsUnpublished(ns, txHash[:])
}

// removeDoubleSpends checks for any unmined transactions which would introduce
// a double spend if tx was added to the store (either as a confirmed or unmined
// transaction). Each conflicting transaction and all transactions which spend