Esempio n. 1
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
}