From 207cf6b64ea4c2487223e023c1cc87570ab6bf5c Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 17 May 2017 21:30:13 +0200 Subject: [PATCH] Add fee tx wrapper --- txs/base.go | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/txs/base.go b/txs/base.go index 235e4b855..04ab877c3 100644 --- a/txs/base.go +++ b/txs/base.go @@ -2,6 +2,7 @@ package txs import ( "github.com/tendermint/basecoin" + "github.com/tendermint/basecoin/types" "github.com/tendermint/go-wire/data" ) @@ -27,12 +28,31 @@ const ( TypeMultiSig = "multisig" ) -// let's register data.Bytes as a "raw" tx, for tests or -// other data we don't want to post.... func init() { - basecoin.TxMapper.RegisterImplementation(data.Bytes{}, TypeRaw, ByteRaw) + basecoin.TxMapper. + RegisterImplementation(data.Bytes{}, TypeRaw, ByteRaw). + RegisterImplementation(&Fee{}, TypeFees, ByteFees) } +// WrapBytes converts data.Bytes into a Tx, so we +// can just pass raw bytes and display in hex in json func WrapBytes(d []byte) basecoin.Tx { return basecoin.Tx{data.Bytes(d)} } + +/**** One Sig ****/ + +// OneSig lets us wrap arbitrary data with a go-crypto signature +type Fee struct { + Tx basecoin.Tx `json:"tx"` + Fee types.Coin `json:"fee"` + // Gas types.Coin `json:"gas"` // ????? +} + +func NewFee(tx basecoin.Tx, fee types.Coin) *Fee { + return &Fee{Tx: tx, Fee: fee} +} + +func (f *Fee) Wrap() basecoin.Tx { + return basecoin.Tx{f} +}