Modify notifyspent handler to take multiple outpoints.

This commit is contained in:
Josh Rickmar 2014-05-06 08:30:36 -05:00
parent a4a79387cc
commit a20fd1ab2c

View file

@ -1419,16 +1419,21 @@ func handleNotifySpent(wsc *wsClient, icmd btcjson.Cmd) (interface{}, *btcjson.E
return nil, &btcjson.ErrInternal
}
blockHash, err := btcwire.NewShaHashFromStr(cmd.OutPoint.Hash)
if err != nil {
return nil, &btcjson.Error{
Code: btcjson.ErrParse.Code,
Message: err.Error(),
outpoints := make([]*btcwire.OutPoint, 0, len(cmd.OutPoints))
for i := range cmd.OutPoints {
blockHash, err := btcwire.NewShaHashFromStr(cmd.OutPoints[i].Hash)
if err != nil {
return nil, &btcjson.Error{
Code: btcjson.ErrParse.Code,
Message: err.Error(),
}
}
index := cmd.OutPoints[i].Index
outpoints = append(outpoints, btcwire.NewOutPoint(blockHash, index))
}
for _, outpoint := range outpoints {
wsc.server.ntfnMgr.RegisterSpentRequest(wsc, outpoint)
}
outpoint := btcwire.NewOutPoint(blockHash, cmd.Index)
wsc.server.ntfnMgr.RegisterSpentRequest(wsc, outpoint)
return nil, nil
}