diff --git a/btcjson/dagsvrresults.go b/btcjson/dagsvrresults.go index 99c92886e..0ed01696a 100644 --- a/btcjson/dagsvrresults.go +++ b/btcjson/dagsvrresults.go @@ -444,6 +444,9 @@ type TxRawResult struct { Size int32 `json:"size,omitempty"` Version int32 `json:"version"` LockTime uint64 `json:"lockTime"` + Subnetwork string `json:"subnetwork"` + Gas uint64 `json:"gas"` + Payload string `json:"payload"` Vin []Vin `json:"vin"` Vout []Vout `json:"vout"` BlockHash string `json:"blockHash,omitempty"` diff --git a/btcjson/dagsvrwsntfns_test.go b/btcjson/dagsvrwsntfns_test.go index 76329aa50..4bbb16b1c 100644 --- a/btcjson/dagsvrwsntfns_test.go +++ b/btcjson/dagsvrwsntfns_test.go @@ -12,7 +12,10 @@ import ( "reflect" "testing" + "github.com/daglabs/btcd/util/subnetworkid" + "github.com/daglabs/btcd/btcjson" + "github.com/daglabs/btcd/wire" ) // TestDAGSvrWsNtfns tests all of the dag server websocket-specific @@ -185,7 +188,7 @@ func TestDAGSvrWsNtfns(t *testing.T) { { name: "txAcceptedVerbose", newNtfn: func() (interface{}, error) { - return btcjson.NewCmd("txAcceptedVerbose", `{"hex":"001122","txid":"123","version":1,"locktime":4294967295,"vin":null,"vout":null,"confirmations":0}`) + return btcjson.NewCmd("txAcceptedVerbose", `{"hex":"001122","txid":"123","version":1,"locktime":4294967295,"subnetwork":"0000000000000000000000000000000000000001","gas":0,"payload":"","vin":null,"vout":null,"confirmations":0}`) }, staticNtfn: func() interface{} { txResult := btcjson.TxRawResult{ @@ -193,19 +196,57 @@ func TestDAGSvrWsNtfns(t *testing.T) { TxID: "123", Version: 1, LockTime: 4294967295, + Subnetwork: wire.SubnetworkIDNative.String(), Vin: nil, Vout: nil, Confirmations: 0, } return btcjson.NewTxAcceptedVerboseNtfn(txResult) }, - marshalled: `{"jsonrpc":"1.0","method":"txAcceptedVerbose","params":[{"hex":"001122","txId":"123","version":1,"lockTime":4294967295,"vin":null,"vout":null,"acceptedBy":null}],"id":null}`, + marshalled: `{"jsonrpc":"1.0","method":"txAcceptedVerbose","params":[{"hex":"001122","txId":"123","version":1,"lockTime":4294967295,"subnetwork":"0000000000000000000000000000000000000001","gas":0,"payload":"","vin":null,"vout":null,"acceptedBy":null}],"id":null}`, unmarshalled: &btcjson.TxAcceptedVerboseNtfn{ RawTx: btcjson.TxRawResult{ Hex: "001122", TxID: "123", Version: 1, LockTime: 4294967295, + Subnetwork: wire.SubnetworkIDNative.String(), + Vin: nil, + Vout: nil, + Confirmations: 0, + }, + }, + }, + { + name: "txAcceptedVerbose with subnetwork, gas and paylaod", + newNtfn: func() (interface{}, error) { + return btcjson.NewCmd("txAcceptedVerbose", `{"hex":"001122","txId":"123","version":1,"lockTime":4294967295,"subnetwork":"000000000000000000000000000000000000432d","gas":10,"payload":"102030","vin":null,"vout":null,"acceptedBy":null}`) + }, + staticNtfn: func() interface{} { + txResult := btcjson.TxRawResult{ + Hex: "001122", + TxID: "123", + Version: 1, + LockTime: 4294967295, + Subnetwork: subnetworkid.SubnetworkID{45, 67}.String(), + Payload: "102030", + Gas: 10, + Vin: nil, + Vout: nil, + Confirmations: 0, + } + return btcjson.NewTxAcceptedVerboseNtfn(txResult) + }, + marshalled: `{"jsonrpc":"1.0","method":"txAcceptedVerbose","params":[{"hex":"001122","txId":"123","version":1,"lockTime":4294967295,"subnetwork":"000000000000000000000000000000000000432d","gas":10,"payload":"102030","vin":null,"vout":null,"acceptedBy":null}],"id":null}`, + unmarshalled: &btcjson.TxAcceptedVerboseNtfn{ + RawTx: btcjson.TxRawResult{ + Hex: "001122", + TxID: "123", + Version: 1, + LockTime: 4294967295, + Subnetwork: subnetworkid.SubnetworkID{45, 67}.String(), + Payload: "102030", + Gas: 10, Vin: nil, Vout: nil, Confirmations: 0, diff --git a/server/rpc/rpcserver.go b/server/rpc/rpcserver.go index 2a450944e..9b9a9d603 100644 --- a/server/rpc/rpcserver.go +++ b/server/rpc/rpcserver.go @@ -751,14 +751,17 @@ func createTxRawResult(dagParams *dagconfig.Params, mtx *wire.MsgTx, } txReply := &btcjson.TxRawResult{ - Hex: mtxHex, - TxID: txID, - Hash: mtx.TxHash().String(), - Size: int32(mtx.SerializeSize()), - Vin: createVinList(mtx), - Vout: createVoutList(mtx, dagParams, nil), - Version: mtx.Version, - LockTime: mtx.LockTime, + Hex: mtxHex, + TxID: txID, + Hash: mtx.TxHash().String(), + Size: int32(mtx.SerializeSize()), + Vin: createVinList(mtx), + Vout: createVoutList(mtx, dagParams, nil), + Version: mtx.Version, + LockTime: mtx.LockTime, + Subnetwork: mtx.SubnetworkID.String(), + Gas: mtx.Gas, + Payload: hex.EncodeToString(mtx.Payload), } if blkHeader != nil { diff --git a/server/rpc/rpcserverhelp.go b/server/rpc/rpcserverhelp.go index db4ddea83..a564db2aa 100644 --- a/server/rpc/rpcserverhelp.go +++ b/server/rpc/rpcserverhelp.go @@ -206,6 +206,9 @@ var helpDescsEnUS = map[string]string{ "txRawResult-txId": "The hash of the transaction", "txRawResult-version": "The transaction version", "txRawResult-lockTime": "The transaction lock time", + "txRawResult-subnetwork": "The transaction subnetwork", + "txRawResult-gas": "The transaction gas", + "txRawResult-payload": "The transaction payload", "txRawResult-vin": "The transaction inputs as JSON objects", "txRawResult-vout": "The transaction outputs as JSON objects", "txRawResult-blockHash": "Hash of the block the transaction is part of",