mirror of
https://github.com/LBRYFoundation/lbcwallet.git
synced 2025-08-30 08:51:29 +00:00
Update notifyspent requests to take multiple outpoints.
This commit is contained in:
parent
437b4cbdbe
commit
909091984b
2 changed files with 17 additions and 12 deletions
20
account.go
20
account.go
|
@ -455,9 +455,7 @@ func (a *Account) Track() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Unable to access unspent outputs: %v", err)
|
log.Errorf("Unable to access unspent outputs: %v", err)
|
||||||
}
|
}
|
||||||
for _, txout := range unspent {
|
ReqSpentUtxoNtfns(unspent)
|
||||||
ReqSpentUtxoNtfn(txout)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// RescanActiveJob creates a RescanJob for all active addresses in the
|
// RescanActiveJob creates a RescanJob for all active addresses in the
|
||||||
|
@ -651,14 +649,18 @@ func (a *Account) ReqNewTxsForAddress(addr btcutil.Address) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReqSpentUtxoNtfn sends a message to btcd to request updates for when
|
// ReqSpentUtxoNtfns sends a message to btcd to request updates for when
|
||||||
// a stored UTXO has been spent.
|
// a stored UTXO has been spent.
|
||||||
func ReqSpentUtxoNtfn(c *tx.Credit) {
|
func ReqSpentUtxoNtfns(credits []*tx.Credit) {
|
||||||
op := c.OutPoint()
|
ops := make([]*btcwire.OutPoint, 0, len(credits))
|
||||||
log.Debugf("Requesting spent UTXO notifications for Outpoint hash %s index %d",
|
for _, c := range credits {
|
||||||
op.Hash, op.Index)
|
op := c.OutPoint()
|
||||||
|
log.Debugf("Requesting spent UTXO notifications for Outpoint " +
|
||||||
|
"hash %s index %d", op.Hash, op.Index)
|
||||||
|
ops = append(ops, op)
|
||||||
|
}
|
||||||
|
|
||||||
NotifySpent(CurrentServerConn(), op)
|
NotifySpent(CurrentServerConn(), ops)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TotalReceived iterates through an account's transaction history, returning the
|
// TotalReceived iterates through an account's transaction history, returning the
|
||||||
|
|
|
@ -351,9 +351,12 @@ func NotifyReceived(rpc ServerConn, addrs []string) *btcjson.Error {
|
||||||
|
|
||||||
// NotifySpent requests notifications for when a transaction is processed which
|
// NotifySpent requests notifications for when a transaction is processed which
|
||||||
// spends op.
|
// spends op.
|
||||||
func NotifySpent(rpc ServerConn, outpoint *btcwire.OutPoint) *btcjson.Error {
|
func NotifySpent(rpc ServerConn, outpoints []*btcwire.OutPoint) *btcjson.Error {
|
||||||
op := btcws.NewOutPointFromWire(outpoint)
|
ops := make([]btcws.OutPoint, 0, len(outpoints))
|
||||||
cmd := btcws.NewNotifySpentCmd(<-NewJSONID, op)
|
for _, op := range outpoints {
|
||||||
|
ops = append(ops, *btcws.NewOutPointFromWire(op))
|
||||||
|
}
|
||||||
|
cmd := btcws.NewNotifySpentCmd(<-NewJSONID, ops)
|
||||||
response := <-rpc.SendRequest(NewServerRequest(cmd))
|
response := <-rpc.SendRequest(NewServerRequest(cmd))
|
||||||
_, jsonErr := response.FinishUnmarshal(nil)
|
_, jsonErr := response.FinishUnmarshal(nil)
|
||||||
return jsonErr
|
return jsonErr
|
||||||
|
|
Loading…
Add table
Reference in a new issue