Cleanup TxInfo
This commit is contained in:
parent
880c1cbaeb
commit
f08da980f0
2 changed files with 22 additions and 19 deletions
|
@ -955,8 +955,8 @@ func GetTransaction(icmd btcjson.Cmd) (interface{}, *btcjson.Error) {
|
||||||
var amountReceived int64
|
var amountReceived int64
|
||||||
|
|
||||||
ret := btcjson.GetTransactionResult{
|
ret := btcjson.GetTransactionResult{
|
||||||
Details: make([]btcjson.GetTransactionDetailsResult, 0),
|
Details: []btcjson.GetTransactionDetailsResult{},
|
||||||
WalletConflicts: make([]string, 0),
|
WalletConflicts: []string{},
|
||||||
}
|
}
|
||||||
details := make([]btcjson.GetTransactionDetailsResult, 0)
|
details := make([]btcjson.GetTransactionDetailsResult, 0)
|
||||||
for _, e := range accumulatedTxen {
|
for _, e := range accumulatedTxen {
|
||||||
|
|
37
tx/tx.go
37
tx/tx.go
|
@ -935,22 +935,23 @@ func (st *SignedTx) TxInfo(account string, chainHeight int32, net btcwire.Bitcoi
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, txout := range st.tx.MsgTx().TxOut {
|
for i, txout := range st.tx.MsgTx().TxOut {
|
||||||
address := "Unknown"
|
var address string
|
||||||
_, addrs, _, _ := btcscript.ExtractPkScriptAddrs(txout.PkScript, net)
|
_, addrs, _, _ := btcscript.ExtractPkScriptAddrs(txout.PkScript, net)
|
||||||
if len(addrs) == 1 {
|
if len(addrs) == 1 {
|
||||||
address = addrs[0].EncodeAddress()
|
address = addrs[0].EncodeAddress()
|
||||||
}
|
}
|
||||||
|
|
||||||
info := btcjson.ListTransactionsResult{
|
info := btcjson.ListTransactionsResult{
|
||||||
Account: account,
|
Account: account,
|
||||||
Address: address,
|
Address: address,
|
||||||
Category: "send",
|
Category: "send",
|
||||||
Amount: float64(-txout.Value) / float64(btcutil.SatoshiPerBitcoin),
|
Amount: float64(-txout.Value) / float64(btcutil.SatoshiPerBitcoin),
|
||||||
Fee: float64(st.Fee()) / float64(btcutil.SatoshiPerBitcoin),
|
Fee: float64(st.Fee()) / float64(btcutil.SatoshiPerBitcoin),
|
||||||
Confirmations: int64(confirmations),
|
Confirmations: int64(confirmations),
|
||||||
TxID: st.txSha.String(),
|
TxID: st.txSha.String(),
|
||||||
Time: st.created.Unix(),
|
Time: st.created.Unix(),
|
||||||
TimeReceived: st.created.Unix(),
|
TimeReceived: st.created.Unix(),
|
||||||
|
WalletConflicts: []string{},
|
||||||
}
|
}
|
||||||
if st.block != nil {
|
if st.block != nil {
|
||||||
info.BlockHash = st.block.Hash.String()
|
info.BlockHash = st.block.Hash.String()
|
||||||
|
@ -1339,19 +1340,21 @@ func (rt *RecvTxOut) TxInfo(account string, chainHeight int32, net btcwire.Bitco
|
||||||
outidx := rt.outpoint.Index
|
outidx := rt.outpoint.Index
|
||||||
txout := tx.TxOut[outidx]
|
txout := tx.TxOut[outidx]
|
||||||
|
|
||||||
address := "Unknown"
|
var address string
|
||||||
_, addrs, _, _ := btcscript.ExtractPkScriptAddrs(txout.PkScript, net)
|
_, addrs, _, _ := btcscript.ExtractPkScriptAddrs(txout.PkScript, net)
|
||||||
if len(addrs) == 1 {
|
if len(addrs) == 1 {
|
||||||
address = addrs[0].EncodeAddress()
|
address = addrs[0].EncodeAddress()
|
||||||
}
|
}
|
||||||
|
|
||||||
result := btcjson.ListTransactionsResult{
|
result := btcjson.ListTransactionsResult{
|
||||||
Account: account,
|
Account: account,
|
||||||
Category: "receive",
|
Category: "receive",
|
||||||
Address: address,
|
Address: address,
|
||||||
Amount: float64(txout.Value) / float64(btcutil.SatoshiPerBitcoin),
|
Amount: float64(txout.Value) / float64(btcutil.SatoshiPerBitcoin),
|
||||||
TxID: rt.outpoint.Hash.String(),
|
TxID: rt.outpoint.Hash.String(),
|
||||||
TimeReceived: rt.received.Unix(),
|
Time: rt.received.Unix(),
|
||||||
|
TimeReceived: rt.received.Unix(),
|
||||||
|
WalletConflicts: []string{},
|
||||||
}
|
}
|
||||||
if rt.block != nil {
|
if rt.block != nil {
|
||||||
result.BlockHash = rt.block.Hash.String()
|
result.BlockHash = rt.block.Hash.String()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue