func (k *Keypair) Transfer(shardID uint32, nonce uint32, to address.Address, amount uint64) (*transfer.ShardTransaction, error) {
	fromPkhBytes := address.HashPubkey(&k.pubkey, shardID)
	var fromPkh [20]byte
	copy(fromPkh[:], fromPkhBytes)

	toPkh, err := to.ToPubkeyHash()
	if err != nil {
		return nil, err
	}

	tx := transfer.ShardTransaction{
		FromPubkeyHash: fromPkh,
		ToPubkeyHash:   toPkh,
		Amount:         amount,
		Nonce:          nonce,
	}

	message := tx.GetTransactionData()

	messageHash := chainhash.HashH(message[:])

	sigBytes, err := secp256k1.SignCompact(&k.key, messageHash[:], false)
	if err != nil {
		return nil, err
	}

	copy(tx.Signature[:], sigBytes)

	return &tx, nil
}
// Transfer creates a transfer transaction to the given address for a given amount.
Transfer creates a transfer transaction to the given address for a given amount.
// Transfer creates a transfer transaction to the given address for a given amount .
func (k *Keypair) Transfer(shardID uint32, nonce uint32, to address.Address, amount uint64) (*transfer.ShardTransaction, error) {
	fromPkhBytes := address.HashPubkey(&k.pubkey, shardID)
	var fromPkh [20]byte
	copy(fromPkh[:], fromPkhBytes)
	toPkh, err := to.ToPubkeyHash()
	if err != nil {
		return nil, err
	}
	tx := transfer.ShardTransaction{
		FromPubkeyHash: fromPkh,
		ToPubkeyHash:   toPkh,
		Amount:         amount,
		Nonce:          nonce,
	}
	message := tx.GetTransactionData()
	messageHash := chainhash.HashH(message[:])
	sigBytes, err := secp256k1.SignCompact(&k.key, messageHash[:], false)
	if err != nil {
		return nil, err
	}
	copy(tx.Signature[:], sigBytes)
	return &tx, nil
}
func ( k * Keypair ) Transfer ( shardID uint32 , nonce uint32 , to address . Address , amount uint64 ) ( * transfer . ShardTransaction , error ) { fromPkhBytes := address . HashPubkey ( & k . pubkey , shardID ) var fromPkh [ 20 ] byte copy ( fromPkh [ : ] , fromPkhBytes ) toPkh , err := to . ToPubkeyHash ( ) if err != nil { return nil , err } tx := transfer . ShardTransaction { FromPubkeyHash : fromPkh , ToPubkeyHash : toPkh , Amount : amount , Nonce : nonce , } message := tx . GetTransactionData ( ) messageHash := chainhash . HashH ( message [ : ] ) sigBytes , err := secp256k1 . SignCompact ( & k . key , messageHash [ : ] , false ) if err != nil { return nil , err } copy ( tx . Signature [ : ] , sigBytes ) return & tx , nil }
Transfer creates a transfer transaction to the given address for a given amount.
Transfer creates a transfer transaction to the given address for a given amount .