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
|
||||
|
||||
ret := btcjson.GetTransactionResult{
|
||||
Details: make([]btcjson.GetTransactionDetailsResult, 0),
|
||||
WalletConflicts: make([]string, 0),
|
||||
Details: []btcjson.GetTransactionDetailsResult{},
|
||||
WalletConflicts: []string{},
|
||||
}
|
||||
details := make([]btcjson.GetTransactionDetailsResult, 0)
|
||||
for _, e := range accumulatedTxen {
|
||||
|
|
7
tx/tx.go
7
tx/tx.go
|
@ -935,7 +935,7 @@ func (st *SignedTx) TxInfo(account string, chainHeight int32, net btcwire.Bitcoi
|
|||
}
|
||||
|
||||
for i, txout := range st.tx.MsgTx().TxOut {
|
||||
address := "Unknown"
|
||||
var address string
|
||||
_, addrs, _, _ := btcscript.ExtractPkScriptAddrs(txout.PkScript, net)
|
||||
if len(addrs) == 1 {
|
||||
address = addrs[0].EncodeAddress()
|
||||
|
@ -951,6 +951,7 @@ func (st *SignedTx) TxInfo(account string, chainHeight int32, net btcwire.Bitcoi
|
|||
TxID: st.txSha.String(),
|
||||
Time: st.created.Unix(),
|
||||
TimeReceived: st.created.Unix(),
|
||||
WalletConflicts: []string{},
|
||||
}
|
||||
if st.block != nil {
|
||||
info.BlockHash = st.block.Hash.String()
|
||||
|
@ -1339,7 +1340,7 @@ func (rt *RecvTxOut) TxInfo(account string, chainHeight int32, net btcwire.Bitco
|
|||
outidx := rt.outpoint.Index
|
||||
txout := tx.TxOut[outidx]
|
||||
|
||||
address := "Unknown"
|
||||
var address string
|
||||
_, addrs, _, _ := btcscript.ExtractPkScriptAddrs(txout.PkScript, net)
|
||||
if len(addrs) == 1 {
|
||||
address = addrs[0].EncodeAddress()
|
||||
|
@ -1351,7 +1352,9 @@ func (rt *RecvTxOut) TxInfo(account string, chainHeight int32, net btcwire.Bitco
|
|||
Address: address,
|
||||
Amount: float64(txout.Value) / float64(btcutil.SatoshiPerBitcoin),
|
||||
TxID: rt.outpoint.Hash.String(),
|
||||
Time: rt.received.Unix(),
|
||||
TimeReceived: rt.received.Unix(),
|
||||
WalletConflicts: []string{},
|
||||
}
|
||||
if rt.block != nil {
|
||||
result.BlockHash = rt.block.Hash.String()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue