예제 #1
0
// Returns the Address hash (what we use for inputs) given the public key
func (w *SCWallet) GetAddressHash(address fct.IAddress) (fct.IAddress, error) {
	_, adr, err := w.getWalletEntry([]byte(fct.W_RCD_ADDRESS_HASH), address)
	if err != nil {
		return nil, err
	}
	return fct.CreateAddress(adr), nil
}
예제 #2
0
func (w *SCWallet) AddECOutput(trans fct.ITransaction, address fct.IAddress, amount uint64) error {

	_, adr, err := w.getWalletEntry([]byte(fct.W_RCD_ADDRESS_HASH), address)
	if err != nil {
		adr = address
	}

	trans.AddECOutput(fct.CreateAddress(adr), amount)
	return nil
}
예제 #3
0
func (w *SCWallet) AddInput(trans fct.ITransaction, address fct.IAddress, amount uint64) error {
	// Check if this is an address we know.
	we, adr, err := w.getWalletEntry([]byte(fct.W_RCD_ADDRESS_HASH), address)
	// If it isn't, we assume the user knows what they are doing.
	if we == nil || err != nil {
		rcd := fct.NewRCD_1(address.Bytes())
		trans.AddRCD(rcd)
		adr, err := rcd.GetAddress()
		if err != nil {
			return err
		}
		trans.AddInput(fct.CreateAddress(adr), amount)
	} else {
		trans.AddRCD(we.GetRCD())
		trans.AddInput(fct.CreateAddress(adr), amount)
	}

	return nil
}