From 102cd553c5b40b4b6af767fde7b7f341f7e3e1e3 Mon Sep 17 00:00:00 2001 From: Josh Rickmar Date: Tue, 9 Feb 2016 09:41:39 -0500 Subject: [PATCH] Set account name for gettransaction results. This only sets the name for any kind of "receiving" category (receive/immature/generate). Fixes #360. --- rpc/legacyrpc/methods.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/rpc/legacyrpc/methods.go b/rpc/legacyrpc/methods.go index 21a6046..243f8d2 100644 --- a/rpc/legacyrpc/methods.go +++ b/rpc/legacyrpc/methods.go @@ -911,19 +911,28 @@ func GetTransaction(icmd interface{}, w *wallet.Wallet) (interface{}, error) { continue } - var addr string + var address string + var accountName string _, addrs, _, err := txscript.ExtractPkScriptAddrs( details.MsgTx.TxOut[cred.Index].PkScript, w.ChainParams()) if err == nil && len(addrs) == 1 { - addr = addrs[0].EncodeAddress() + addr := addrs[0] + address = addr.EncodeAddress() + account, err := w.Manager.AddrAccount(addr) + if err == nil { + accountName, err = w.Manager.AccountName(account) + if err != nil { + accountName = "" + } + } } ret.Details = append(ret.Details, btcjson.GetTransactionDetailsResult{ // Fields left zeroed: // InvolvesWatchOnly - // Account // Fee - Address: addr, + Account: accountName, + Address: address, Category: credCat, Amount: cred.Amount.ToBTC(), Vout: cred.Index,