コード例 #1
0
func (tx *SendTx) AddInput(st AccountGetter, pubkey acm.PubKey, amt int64) error {
	addr := pubkey.Address()
	acc := st.GetAccount(addr)
	if acc == nil {
		return fmt.Errorf("Invalid address %X from pubkey %X", addr, pubkey)
	}
	return tx.AddInputWithNonce(pubkey, amt, acc.Sequence+1)
}
コード例 #2
0
func NewCallTx(st AccountGetter, from acm.PubKey, to, data []byte, amt, gasLimit, fee int64) (*CallTx, error) {
	addr := from.Address()
	acc := st.GetAccount(addr)
	if acc == nil {
		return nil, fmt.Errorf("Invalid address %X from pubkey %X", addr, from)
	}

	nonce := acc.Sequence + 1
	return NewCallTxWithNonce(from, to, data, amt, gasLimit, fee, nonce), nil
}
コード例 #3
0
func NewPermissionsTx(st AccountGetter, from acm.PubKey, args ptypes.PermArgs) (*PermissionsTx, error) {
	addr := from.Address()
	acc := st.GetAccount(addr)
	if acc == nil {
		return nil, fmt.Errorf("Invalid address %X from pubkey %X", addr, from)
	}

	nonce := acc.Sequence + 1
	return NewPermissionsTxWithNonce(from, args, nonce), nil
}
コード例 #4
0
func NewNameTx(st AccountGetter, from acm.PubKey, name, data string, amt, fee int64) (*NameTx, error) {
	addr := from.Address()
	acc := st.GetAccount(addr)
	if acc == nil {
		return nil, fmt.Errorf("Invalid address %X from pubkey %X", addr, from)
	}

	nonce := acc.Sequence + 1
	return NewNameTxWithNonce(from, name, data, amt, fee, nonce), nil
}
コード例 #5
0
func (tx *SendTx) AddInputWithNonce(pubkey acm.PubKey, amt int64, nonce int) error {
	addr := pubkey.Address()
	tx.Inputs = append(tx.Inputs, &TxInput{
		Address:   addr,
		Amount:    amt,
		Sequence:  nonce,
		Signature: acm.SignatureEd25519{},
		PubKey:    pubkey,
	})
	return nil
}
コード例 #6
0
func NewPermissionsTxWithNonce(from acm.PubKey, args ptypes.PermArgs, nonce int) *PermissionsTx {
	addr := from.Address()
	input := &TxInput{
		Address:   addr,
		Amount:    1, // NOTE: amounts can't be 0 ...
		Sequence:  nonce,
		Signature: acm.SignatureEd25519{},
		PubKey:    from,
	}

	return &PermissionsTx{
		Input:    input,
		PermArgs: args,
	}
}
コード例 #7
0
func NewNameTxWithNonce(from acm.PubKey, name, data string, amt, fee int64, nonce int) *NameTx {
	addr := from.Address()
	input := &TxInput{
		Address:   addr,
		Amount:    amt,
		Sequence:  nonce,
		Signature: acm.SignatureEd25519{},
		PubKey:    from,
	}

	return &NameTx{
		Input: input,
		Name:  name,
		Data:  data,
		Fee:   fee,
	}
}
コード例 #8
0
func NewCallTxWithNonce(from acm.PubKey, to, data []byte, amt, gasLimit, fee int64, nonce int) *CallTx {
	addr := from.Address()
	input := &TxInput{
		Address:   addr,
		Amount:    amt,
		Sequence:  nonce,
		Signature: acm.SignatureEd25519{},
		PubKey:    from,
	}

	return &CallTx{
		Input:    input,
		Address:  to,
		GasLimit: gasLimit,
		Fee:      fee,
		Data:     data,
	}
}