diff --git a/account/private_account.go b/account/private_account.go index 9b705a02d518ede77b9047bc4288473259fff961..120adf54d2896665197071267d9086f4d0414f4d 100644 --- a/account/private_account.go +++ b/account/private_account.go @@ -20,12 +20,16 @@ import ( "github.com/tendermint/go-wire" ) -type PrivateAccount interface { +type SigningAccount interface { Addressable - PrivateKey() PrivateKey Signer } +type PrivateAccount interface { + SigningAccount + PrivateKey() PrivateKey +} + // type ConcretePrivateAccount struct { Address Address @@ -82,8 +86,8 @@ func (pa ConcretePrivateAccount) Sign(msg []byte) (Signature, error) { return pa.PrivateKey.Sign(msg) } -func ChainSign(pa PrivateAccount, chainID string, o Signable) Signature { - sig, err := pa.Sign(SignBytes(chainID, o)) +func ChainSign(signer Signer, chainID string, o Signable) Signature { + sig, err := signer.Sign(SignBytes(chainID, o)) if err != nil { panic(err) } @@ -94,13 +98,13 @@ func (pa *ConcretePrivateAccount) String() string { return fmt.Sprintf("ConcretePrivateAccount{%s}", pa.Address) } -// Convert slice of ConcretePrivateAccounts to slice of PrivateAccounts -func PrivateAccounts(concretePrivateAccounts []*ConcretePrivateAccount) []PrivateAccount { - privateAccounts := make([]PrivateAccount, len(concretePrivateAccounts)) +// Convert slice of ConcretePrivateAccounts to slice of SigningAccounts +func SigningAccounts(concretePrivateAccounts []*ConcretePrivateAccount) []SigningAccount { + signingAccounts := make([]SigningAccount, len(concretePrivateAccounts)) for i, cpa := range concretePrivateAccounts { - privateAccounts[i] = cpa.PrivateAccount() + signingAccounts[i] = cpa.PrivateAccount() } - return privateAccounts + return signingAccounts } // Generates a new account with private key. diff --git a/blockchain/blockchain.go b/blockchain/blockchain.go index dae49f81adc865be17b0c5f4d9d6fc1a9dee0975..26e3eb5b0ace3e665d9dc4f25c58ef7212a801d0 100644 --- a/blockchain/blockchain.go +++ b/blockchain/blockchain.go @@ -31,8 +31,6 @@ var stateKey = []byte("BlockchainState") // Immutable Root of blockchain type Root interface { - // ChainID precomputed from GenesisDoc - ChainID() string // GenesisHash precomputed from GenesisDoc GenesisHash() []byte GenesisDoc() genesis.GenesisDoc @@ -40,6 +38,8 @@ type Root interface { // Immutable pointer to the current tip of the blockchain type Tip interface { + // ChainID precomputed from GenesisDoc + ChainID() string // All Last* references are to the block last committed LastBlockHeight() uint64 LastBlockTime() time.Time @@ -66,12 +66,12 @@ type MutableBlockchain interface { } type root struct { - chainID string genesisHash []byte genesisDoc genesis.GenesisDoc } type tip struct { + chainID string lastBlockHeight uint64 lastBlockTime time.Time lastBlockHash []byte @@ -159,15 +159,15 @@ func LoadBlockchain(db dbm.DB) (*blockchain, error) { func NewRoot(genesisDoc *genesis.GenesisDoc) *root { return &root{ - chainID: genesisDoc.ChainID(), genesisHash: genesisDoc.Hash(), genesisDoc: *genesisDoc, } } // Create -func NewTip(lastBlockHeight uint64, lastBlockTime time.Time, lastBlockHash []byte, appHashAfterLastBlock []byte) *tip { +func NewTip(chainID string, lastBlockHeight uint64, lastBlockTime time.Time, lastBlockHash []byte, appHashAfterLastBlock []byte) *tip { return &tip{ + chainID: chainID, lastBlockHeight: lastBlockHeight, lastBlockTime: lastBlockTime, lastBlockHash: lastBlockHash, @@ -239,10 +239,6 @@ func Decode(encodedState []byte) (*PersistedState, error) { return persistedState, nil } -func (r *root) ChainID() string { - return r.chainID -} - func (r *root) GenesisHash() []byte { return r.genesisHash } @@ -251,6 +247,10 @@ func (r *root) GenesisDoc() genesis.GenesisDoc { return r.genesisDoc } +func (t *tip) ChainID() string { + return t.chainID +} + func (t *tip) LastBlockHeight() uint64 { return t.lastBlockHeight } diff --git a/execution/execution_test.go b/execution/execution_test.go index 70c9fe37010d22db449edd90e59ba4d668311f12..9e20db6b7cf0629d39279591a79d996757eaea52 100644 --- a/execution/execution_test.go +++ b/execution/execution_test.go @@ -119,8 +119,8 @@ var testGenesisDoc, testPrivAccounts, _ = deterministicGenesis. GenesisDoc(3, true, 1000, 1, true, 1000) var testChainID = testGenesisDoc.ChainID() -func makeUsers(n int) []acm.PrivateAccount { - users := make([]acm.PrivateAccount, n) +func makeUsers(n int) []acm.SigningAccount { + users := make([]acm.SigningAccount, n) for i := 0; i < n; i++ { secret := "mysecret" + strconv.Itoa(i) users[i] = acm.GeneratePrivateAccountFromSecret(secret) @@ -1708,7 +1708,7 @@ func execTxWithStateNewBlock(state *State, blockchain bcm.MutableBlockchain, tx } func makeGenesisState(numAccounts int, randBalance bool, minBalance uint64, numValidators int, randBonded bool, - minBonded int64) (*State, []acm.PrivateAccount) { + minBonded int64) (*State, []acm.SigningAccount) { testGenesisDoc, privAccounts, _ := deterministicGenesis.GenesisDoc(numAccounts, randBalance, minBalance, numValidators, randBonded, minBonded) s0, err := MakeGenesisState(dbm.NewMemDB(), testGenesisDoc) @@ -1865,7 +1865,7 @@ func permNameToFuncID(name string) []byte { return id[:] } -func snativePermTestInputCALL(name string, user acm.PrivateAccount, perm ptypes.PermFlag, +func snativePermTestInputCALL(name string, user acm.SigningAccount, perm ptypes.PermFlag, val bool) (addr acm.Address, pF ptypes.PermFlag, data []byte) { addr = permissionsContract.Address() switch name { @@ -1888,7 +1888,7 @@ func snativePermTestInputCALL(name string, user acm.PrivateAccount, perm ptypes. return } -func snativePermTestInputTx(name string, user acm.PrivateAccount, perm ptypes.PermFlag, +func snativePermTestInputTx(name string, user acm.SigningAccount, perm ptypes.PermFlag, val bool) (snativeArgs snatives.PermArgs) { switch name { @@ -1904,7 +1904,7 @@ func snativePermTestInputTx(name string, user acm.PrivateAccount, perm ptypes.Pe return } -func snativeRoleTestInputCALL(name string, user acm.PrivateAccount, +func snativeRoleTestInputCALL(name string, user acm.SigningAccount, role string) (addr acm.Address, pF ptypes.PermFlag, data []byte) { addr = permissionsContract.Address() data = user.Address().Word256().Bytes() @@ -1918,7 +1918,7 @@ func snativeRoleTestInputCALL(name string, user acm.PrivateAccount, return } -func snativeRoleTestInputTx(name string, user acm.PrivateAccount, role string) (snativeArgs snatives.PermArgs) { +func snativeRoleTestInputTx(name string, user acm.SigningAccount, role string) (snativeArgs snatives.PermArgs) { switch name { case "hasRole": snativeArgs = snatives.HasRoleArgs(user.Address(), role) diff --git a/execution/transactor.go b/execution/transactor.go index 9050949dc451ab537b6ee653e76f80636e659eea..7d0a81c76f0f835c74228e251077545183cc69eb 100644 --- a/execution/transactor.go +++ b/execution/transactor.go @@ -45,37 +45,22 @@ type Call struct { GasUsed uint64 } -type Transactor interface { - Call(fromAddress, toAddress acm.Address, data []byte) (*Call, error) - CallCode(fromAddress acm.Address, code, data []byte) (*Call, error) - BroadcastTx(tx txs.Tx) (*txs.Receipt, error) - BroadcastTxAsync(tx txs.Tx, callback func(res *abci_types.Response)) error - Transact(privKey []byte, address *acm.Address, data []byte, gasLimit, fee uint64) (*txs.Receipt, error) - TransactAndHold(privKey []byte, address *acm.Address, data []byte, gasLimit, fee uint64) (*evm_events.EventDataCall, error) - Send(privKey []byte, toAddress acm.Address, amount uint64) (*txs.Receipt, error) - SendAndHold(privKey []byte, toAddress acm.Address, amount uint64) (*txs.Receipt, error) - TransactNameReg(privKey []byte, name, data string, amount, fee uint64) (*txs.Receipt, error) - SignTx(tx txs.Tx, privAccounts []acm.PrivateAccount) (txs.Tx, error) -} - // Transactor is the controller/middleware for the v0 RPC -type transactor struct { +type Transactor struct { txMtx sync.Mutex - blockchain blockchain.Blockchain + tip blockchain.Tip state state.Iterable eventEmitter event.Emitter broadcastTxAsync func(tx txs.Tx, callback func(res *abci_types.Response)) error logger *logging.Logger } -var _ Transactor = &transactor{} - -func NewTransactor(blockchain blockchain.Blockchain, state state.Iterable, eventEmitter event.Emitter, +func NewTransactor(tip blockchain.Tip, state state.Iterable, eventEmitter event.Emitter, broadcastTxAsync func(tx txs.Tx, callback func(res *abci_types.Response)) error, - logger *logging.Logger) *transactor { + logger *logging.Logger) *Transactor { - return &transactor{ - blockchain: blockchain, + return &Transactor{ + tip: tip, state: state, eventEmitter: eventEmitter, broadcastTxAsync: broadcastTxAsync, @@ -85,7 +70,7 @@ func NewTransactor(blockchain blockchain.Blockchain, state state.Iterable, event // Run a contract's code on an isolated and unpersisted state // Cannot be used to create new contracts -func (trans *transactor) Call(fromAddress, toAddress acm.Address, data []byte) (call *Call, err error) { +func (trans *Transactor) Call(fromAddress, toAddress acm.Address, data []byte) (call *Call, err error) { if evm.RegisteredNativeContract(toAddress.Word256()) { return nil, fmt.Errorf("attempt to call native contract at address "+ "%X, but native contracts can not be called directly. Use a deployed "+ @@ -101,7 +86,7 @@ func (trans *transactor) Call(fromAddress, toAddress acm.Address, data []byte) ( } caller := acm.ConcreteAccount{Address: fromAddress}.MutableAccount() txCache := state.NewCache(trans.state) - params := vmParams(trans.blockchain) + params := vmParams(trans.tip) vmach := evm.NewVM(txCache, params, caller.Address(), nil, trans.logger.WithScope("Call")) vmach.SetPublisher(trans.eventEmitter) @@ -122,12 +107,12 @@ func (trans *transactor) Call(fromAddress, toAddress acm.Address, data []byte) ( // Run the given code on an isolated and unpersisted state // Cannot be used to create new contracts. -func (trans *transactor) CallCode(fromAddress acm.Address, code, data []byte) (*Call, error) { +func (trans *Transactor) CallCode(fromAddress acm.Address, code, data []byte) (*Call, error) { // This was being run against CheckTx cache, need to understand the reasoning callee := acm.ConcreteAccount{Address: fromAddress}.MutableAccount() caller := acm.ConcreteAccount{Address: fromAddress}.MutableAccount() txCache := state.NewCache(trans.state) - params := vmParams(trans.blockchain) + params := vmParams(trans.tip) vmach := evm.NewVM(txCache, params, caller.Address(), nil, trans.logger.WithScope("CallCode")) gas := params.GasLimit @@ -139,14 +124,14 @@ func (trans *transactor) CallCode(fromAddress acm.Address, code, data []byte) (* return &Call{Return: ret, GasUsed: gasUsed}, nil } -func (trans *transactor) BroadcastTxAsync(tx txs.Tx, callback func(res *abci_types.Response)) error { +func (trans *Transactor) BroadcastTxAsync(tx txs.Tx, callback func(res *abci_types.Response)) error { return trans.broadcastTxAsync(tx, callback) } // Broadcast a transaction. -func (trans *transactor) BroadcastTx(tx txs.Tx) (*txs.Receipt, error) { +func (trans *Transactor) BroadcastTx(tx txs.Tx) (*txs.Receipt, error) { trans.logger.Trace.Log("method", "BroadcastTx", - "tx_hash", tx.Hash(trans.blockchain.ChainID()), + "tx_hash", tx.Hash(trans.tip.ChainID()), "tx", tx.String()) responseCh := make(chan *abci_types.Response, 1) err := trans.BroadcastTxAsync(tx, func(res *abci_types.Response) { @@ -177,7 +162,7 @@ func (trans *transactor) BroadcastTx(tx txs.Tx) (*txs.Receipt, error) { } // Orders calls to BroadcastTx using lock (waits for response from core before releasing) -func (trans *transactor) Transact(privKey []byte, address *acm.Address, data []byte, gasLimit, +func (trans *Transactor) Transact(privKey []byte, address *acm.Address, data []byte, gasLimit, fee uint64) (*txs.Receipt, error) { if len(privKey) != 64 { @@ -198,6 +183,7 @@ func (trans *transactor) Transact(privKey []byte, address *acm.Address, data []b if acc != nil { sequence = acc.Sequence() + uint64(1) } + // TODO: [Silas] we should consider revising this method and removing fee, or // possibly adding an amount parameter. It is non-sensical to just be able to // set the fee. Our support of fees in general is questionable since at the @@ -224,14 +210,14 @@ func (trans *transactor) Transact(privKey []byte, address *acm.Address, data []b } // Got ourselves a tx. - txS, errS := trans.SignTx(tx, []acm.PrivateAccount{pa}) + txS, errS := trans.SignTx(tx, []acm.SigningAccount{pa}) if errS != nil { return nil, errS } return trans.BroadcastTx(txS) } -func (trans *transactor) TransactAndHold(privKey []byte, address *acm.Address, data []byte, gasLimit, +func (trans *Transactor) TransactAndHold(privKey []byte, address *acm.Address, data []byte, gasLimit, fee uint64) (*evm_events.EventDataCall, error) { receipt, err := trans.Transact(privKey, address, data, gasLimit, fee) @@ -271,7 +257,7 @@ func (trans *transactor) TransactAndHold(privKey []byte, address *acm.Address, d } } -func (trans *transactor) Send(privKey []byte, toAddress acm.Address, amount uint64) (*txs.Receipt, error) { +func (trans *Transactor) Send(privKey []byte, toAddress acm.Address, amount uint64) (*txs.Receipt, error) { if len(privKey) != 64 { return nil, fmt.Errorf("Private key is not of the right length: %d\n", len(privKey)) @@ -311,14 +297,14 @@ func (trans *transactor) Send(privKey []byte, toAddress acm.Address, amount uint tx.Outputs = append(tx.Outputs, txOutput) // Got ourselves a tx. - txS, errS := trans.SignTx(tx, []acm.PrivateAccount{pa}) + txS, errS := trans.SignTx(tx, []acm.SigningAccount{pa}) if errS != nil { return nil, errS } return trans.BroadcastTx(txS) } -func (trans *transactor) SendAndHold(privKey []byte, toAddress acm.Address, amount uint64) (*txs.Receipt, error) { +func (trans *Transactor) SendAndHold(privKey []byte, toAddress acm.Address, amount uint64) (*txs.Receipt, error) { receipt, err := trans.Send(privKey, toAddress, amount) if err != nil { return nil, err @@ -359,7 +345,7 @@ func (trans *transactor) SendAndHold(privKey []byte, toAddress acm.Address, amou } } -func (trans *transactor) TransactNameReg(privKey []byte, name, data string, amount, fee uint64) (*txs.Receipt, error) { +func (trans *Transactor) TransactNameReg(privKey []byte, name, data string, amount, fee uint64) (*txs.Receipt, error) { if len(privKey) != 64 { return nil, fmt.Errorf("Private key is not of the right length: %d\n", len(privKey)) @@ -381,7 +367,7 @@ func (trans *transactor) TransactNameReg(privKey []byte, name, data string, amou } tx := txs.NewNameTxWithSequence(pa.PublicKey(), name, data, amount, fee, sequence) // Got ourselves a tx. - txS, errS := trans.SignTx(tx, []acm.PrivateAccount{pa}) + txS, errS := trans.SignTx(tx, []acm.SigningAccount{pa}) if errS != nil { return nil, errS } @@ -389,15 +375,10 @@ func (trans *transactor) TransactNameReg(privKey []byte, name, data string, amou } // Sign a transaction -func (trans *transactor) SignTx(tx txs.Tx, privAccounts []acm.PrivateAccount) (txs.Tx, error) { +func (trans *Transactor) SignTx(tx txs.Tx, privAccounts []acm.SigningAccount) (txs.Tx, error) { // more checks? - for i, privAccount := range privAccounts { - if privAccount == nil || privAccount.PrivateKey().Unwrap() == nil { - return nil, fmt.Errorf("invalid (empty) privAccount @%v", i) - } - } - chainID := trans.blockchain.ChainID() + chainID := trans.tip.ChainID() switch tx.(type) { case *txs.NameTx: nameTx := tx.(*txs.NameTx) @@ -434,8 +415,7 @@ func (trans *transactor) SignTx(tx txs.Tx, privAccounts []acm.PrivateAccount) (t return tx, nil } -func vmParams(blockchain blockchain.Blockchain) evm.Params { - tip := blockchain.Tip() +func vmParams(tip blockchain.Tip) evm.Params { return evm.Params{ BlockHeight: tip.LastBlockHeight(), BlockHash: binary.LeftPadWord256(tip.LastBlockHash()), diff --git a/genesis/deterministic_genesis.go b/genesis/deterministic_genesis.go index 402a588bdc2afb617404b82469b46c159f3d820a..eeac035ed1ed25489c5b05d7c055b7ede8884a43 100644 --- a/genesis/deterministic_genesis.go +++ b/genesis/deterministic_genesis.go @@ -21,10 +21,10 @@ func NewDeterministicGenesis(seed int64) *deterministicGenesis { } func (dg *deterministicGenesis) GenesisDoc(numAccounts int, randBalance bool, minBalance uint64, numValidators int, - randBonded bool, minBonded int64) (*GenesisDoc, []acm.PrivateAccount, []acm.PrivateAccount) { + randBonded bool, minBonded int64) (*GenesisDoc, []acm.SigningAccount, []acm.SigningAccount) { accounts := make([]Account, numAccounts) - privAccounts := make([]acm.PrivateAccount, numAccounts) + privAccounts := make([]acm.SigningAccount, numAccounts) defaultPerms := permission.DefaultAccountPermissions for i := 0; i < numAccounts; i++ { account, privAccount := dg.Account(randBalance, minBalance) @@ -38,7 +38,7 @@ func (dg *deterministicGenesis) GenesisDoc(numAccounts int, randBalance bool, mi privAccounts[i] = privAccount } validators := make([]Validator, numValidators) - privValidators := make([]acm.PrivateAccount, numValidators) + privValidators := make([]acm.SigningAccount, numValidators) for i := 0; i < numValidators; i++ { validator := acm.GeneratePrivateAccountFromSecret(fmt.Sprintf("val_%v", i)) privValidators[i] = validator @@ -65,7 +65,7 @@ func (dg *deterministicGenesis) GenesisDoc(numAccounts int, randBalance bool, mi } -func (dg *deterministicGenesis) Account(randBalance bool, minBalance uint64) (acm.Account, acm.PrivateAccount) { +func (dg *deterministicGenesis) Account(randBalance bool, minBalance uint64) (acm.Account, acm.SigningAccount) { privateKey, err := acm.GeneratePrivateKey(dg.random) if err != nil { panic(fmt.Errorf("could not generate private key deterministically")) diff --git a/rpc/service.go b/rpc/service.go index 13d698346c30f135f78793536539b3263cff6eb9..dedc5952382522accd69a24226443ea7018f7516 100644 --- a/rpc/service.go +++ b/rpc/service.go @@ -45,13 +45,13 @@ type Service struct { subscribable event.Subscribable nameReg execution.NameRegIterable blockchain bcm.Blockchain - transactor execution.Transactor + transactor *execution.Transactor nodeView query.NodeView logger *logging.Logger } func NewService(ctx context.Context, iterable state.Iterable, nameReg execution.NameRegIterable, - subscribable event.Subscribable, blockchain bcm.Blockchain, transactor execution.Transactor, + subscribable event.Subscribable, blockchain bcm.Blockchain, transactor *execution.Transactor, nodeView query.NodeView, logger *logging.Logger) *Service { return &Service{ @@ -77,7 +77,7 @@ func NewSubscribableService(subscribable event.Subscribable, logger *logging.Log // Transacting... -func (s *Service) Transactor() execution.Transactor { +func (s *Service) Transactor() *execution.Transactor { return s.transactor } diff --git a/rpc/tm/integration/shared.go b/rpc/tm/integration/shared.go index 2849634c4418dd5e1219ca256fe8c7ac93bbc037..0844aa2b49ff097b651c0e0514a7af1f28d817d1 100644 --- a/rpc/tm/integration/shared.go +++ b/rpc/tm/integration/shared.go @@ -144,8 +144,8 @@ func testGenesisDoc() *genesis.GenesisDoc { } // Deterministic account generation helper. Pass number of accounts to make -func makePrivateAccounts(n int) []acm.PrivateAccount { - accounts := make([]acm.PrivateAccount, n) +func makePrivateAccounts(n int) []acm.SigningAccount { + accounts := make([]acm.SigningAccount, n) for i := 0; i < n; i++ { accounts[i] = acm.GeneratePrivateAccountFromSecret("mysecret" + strconv.Itoa(i)) } diff --git a/rpc/tm/methods.go b/rpc/tm/methods.go index 719f8cd1e4c927a6e98c6649db5b77327eff61fd..0b8e355c93eb850eefa30ed6687de7c416bb616a 100644 --- a/rpc/tm/methods.go +++ b/rpc/tm/methods.go @@ -73,7 +73,7 @@ func GetRoutes(service *rpc.Service, logger *logging.Logger) map[string]*gorpc.R }, "tx"), SignTx: gorpc.NewRPCFunc(func(tx txs.Tx, concretePrivateAccounts []*acm.ConcretePrivateAccount) (*rpc.ResultSignTx, error) { - tx, err := service.Transactor().SignTx(tx, acm.PrivateAccounts(concretePrivateAccounts)) + tx, err := service.Transactor().SignTx(tx, acm.SigningAccounts(concretePrivateAccounts)) return &rpc.ResultSignTx{Tx: txs.Wrap(tx)}, err }, "tx,privAccounts"), diff --git a/rpc/v0/methods.go b/rpc/v0/methods.go index ef994e04dc76916301f9428fdf6255948c7cf2c2..3d5c98b72bbe8e2ecf46a693c95ebefe61acd921 100644 --- a/rpc/v0/methods.go +++ b/rpc/v0/methods.go @@ -213,7 +213,7 @@ func GetMethods(codec rpc.Codec, service *rpc.Service, logger *logging.Logger) m if err != nil { return nil, rpc.INVALID_PARAMS, err } - txRet, err := service.Transactor().SignTx(param.Tx, acm.PrivateAccounts(param.PrivAccounts)) + txRet, err := service.Transactor().SignTx(param.Tx, acm.SigningAccounts(param.PrivAccounts)) if err != nil { return nil, rpc.INTERNAL_ERROR, err } diff --git a/txs/tx_utils.go b/txs/tx_utils.go index dd5ddae2455d1e718e05535d07b8376aa4081b56..e1b8a8a4f8d7be8f4108a2a145464104c9d9370a 100644 --- a/txs/tx_utils.go +++ b/txs/tx_utils.go @@ -63,7 +63,7 @@ func (tx *SendTx) AddOutput(addr acm.Address, amt uint64) error { return nil } -func (tx *SendTx) SignInput(chainID string, i int, privAccount acm.PrivateAccount) error { +func (tx *SendTx) SignInput(chainID string, i int, privAccount acm.SigningAccount) error { if i >= len(tx.Inputs) { return fmt.Errorf("Index %v is greater than number of inputs (%v)", i, len(tx.Inputs)) } @@ -109,7 +109,7 @@ func NewCallTxWithSequence(from acm.PublicKey, to *acm.Address, data []byte, } } -func (tx *CallTx) Sign(chainID string, privAccount acm.PrivateAccount) { +func (tx *CallTx) Sign(chainID string, privAccount acm.SigningAccount) { tx.Input.PublicKey = privAccount.PublicKey() tx.Input.Signature = acm.ChainSign(privAccount, chainID, tx) } @@ -147,7 +147,7 @@ func NewNameTxWithSequence(from acm.PublicKey, name, data string, amt, fee, sequ } } -func (tx *NameTx) Sign(chainID string, privAccount acm.PrivateAccount) { +func (tx *NameTx) Sign(chainID string, privAccount acm.SigningAccount) { tx.Input.PublicKey = privAccount.PublicKey() tx.Input.Signature = acm.ChainSign(privAccount, chainID, tx) } @@ -193,12 +193,12 @@ func (tx *BondTx) AddOutput(addr acm.Address, amt uint64) error { return nil } -func (tx *BondTx) SignBond(chainID string, privAccount acm.PrivateAccount) error { +func (tx *BondTx) SignBond(chainID string, privAccount acm.SigningAccount) error { tx.Signature = acm.ChainSign(privAccount, chainID, tx) return nil } -func (tx *BondTx) SignInput(chainID string, i int, privAccount acm.PrivateAccount) error { +func (tx *BondTx) SignInput(chainID string, i int, privAccount acm.SigningAccount) error { if i >= len(tx.Inputs) { return fmt.Errorf("Index %v is greater than number of inputs (%v)", i, len(tx.Inputs)) } @@ -217,7 +217,7 @@ func NewUnbondTx(addr acm.Address, height int) *UnbondTx { } } -func (tx *UnbondTx) Sign(chainID string, privAccount acm.PrivateAccount) { +func (tx *UnbondTx) Sign(chainID string, privAccount acm.SigningAccount) { tx.Signature = acm.ChainSign(privAccount, chainID, tx) } @@ -231,7 +231,7 @@ func NewRebondTx(addr acm.Address, height int) *RebondTx { } } -func (tx *RebondTx) Sign(chainID string, privAccount acm.PrivateAccount) { +func (tx *RebondTx) Sign(chainID string, privAccount acm.SigningAccount) { tx.Signature = acm.ChainSign(privAccount, chainID, tx) } @@ -266,7 +266,7 @@ func NewPermissionsTxWithSequence(from acm.PublicKey, args snatives.PermArgs, se } } -func (tx *PermissionsTx) Sign(chainID string, privAccount acm.PrivateAccount) { +func (tx *PermissionsTx) Sign(chainID string, privAccount acm.SigningAccount) { tx.Input.PublicKey = privAccount.PublicKey() tx.Input.Signature = acm.ChainSign(privAccount, chainID, tx) }