Use the correct message reply routing for sending transactions.
This commit is contained in:
parent
acbb9076cd
commit
154a962173
1 changed files with 36 additions and 16 deletions
40
cmdmgr.go
40
cmdmgr.go
|
@ -466,7 +466,7 @@ func SendFrom(reply chan []byte, msg *btcjson.Message) {
|
||||||
|
|
||||||
// Send rawtx off to btcd
|
// Send rawtx off to btcd
|
||||||
n := <-NewJsonID
|
n := <-NewJsonID
|
||||||
var id interface{} = fmt.Sprintf("btcwallet(%v)-%v", n, msg.Id)
|
var id interface{} = fmt.Sprintf("btcwallet(%v)", n)
|
||||||
m, err := btcjson.CreateMessageWithId("sendrawtransaction", id,
|
m, err := btcjson.CreateMessageWithId("sendrawtransaction", id,
|
||||||
hex.EncodeToString(rawtx))
|
hex.EncodeToString(rawtx))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -475,14 +475,24 @@ func SendFrom(reply chan []byte, msg *btcjson.Message) {
|
||||||
ReplyError(reply, msg.Id, &e)
|
ReplyError(reply, msg.Id, &e)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
replyRouter.Lock()
|
replyHandlers.Lock()
|
||||||
replyRouter.m[n] = reply
|
replyHandlers.m[n] = func(result interface{}, err *btcjson.Error) bool {
|
||||||
replyRouter.Unlock()
|
if err != nil {
|
||||||
btcdMsgs <- m
|
ReplyError(reply, msg.Id, err)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// TODO(jrick): If message succeeded in being sent, save the
|
// TODO(jrick): If message succeeded in being sent, save the
|
||||||
// transaction details with comments.
|
// transaction details with comments.
|
||||||
_, _ = comment, commentto
|
_, _ = comment, commentto
|
||||||
|
|
||||||
|
// TODO(jrick): remove previous unspent outputs now spent by the tx.
|
||||||
|
|
||||||
|
ReplySuccess(reply, msg.Id, result)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
replyHandlers.Unlock()
|
||||||
|
btcdMsgs <- m
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendMany creates a new transaction spending unspent transaction
|
// SendMany creates a new transaction spending unspent transaction
|
||||||
|
@ -579,7 +589,7 @@ func SendMany(reply chan []byte, msg *btcjson.Message) {
|
||||||
|
|
||||||
// Send rawtx off to btcd
|
// Send rawtx off to btcd
|
||||||
n := <-NewJsonID
|
n := <-NewJsonID
|
||||||
var id interface{} = fmt.Sprintf("btcwallet(%v)-%v", n, msg.Id)
|
var id interface{} = fmt.Sprintf("btcwallet(%v)", n)
|
||||||
m, err := btcjson.CreateMessageWithId("sendrawtransaction", id,
|
m, err := btcjson.CreateMessageWithId("sendrawtransaction", id,
|
||||||
hex.EncodeToString(rawtx))
|
hex.EncodeToString(rawtx))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -588,14 +598,24 @@ func SendMany(reply chan []byte, msg *btcjson.Message) {
|
||||||
ReplyError(reply, msg.Id, &e)
|
ReplyError(reply, msg.Id, &e)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
replyRouter.Lock()
|
replyHandlers.Lock()
|
||||||
replyRouter.m[n] = reply
|
replyHandlers.m[n] = func(result interface{}, err *btcjson.Error) bool {
|
||||||
replyRouter.Unlock()
|
if err != nil {
|
||||||
btcdMsgs <- m
|
ReplyError(reply, msg.Id, err)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// TODO(jrick): If message succeeded in being sent, save the
|
// TODO(jrick): If message succeeded in being sent, save the
|
||||||
// transaction details with comments.
|
// transaction details with comments.
|
||||||
_ = comment
|
_ = comment
|
||||||
|
|
||||||
|
// TODO(jrick): remove previous unspent outputs now spent by the tx.
|
||||||
|
|
||||||
|
ReplySuccess(reply, msg.Id, result)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
replyHandlers.Unlock()
|
||||||
|
btcdMsgs <- m
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetTxFee sets the global transaction fee added to transactions.
|
// SetTxFee sets the global transaction fee added to transactions.
|
||||||
|
|
Loading…
Reference in a new issue