// Convert Factoid and Entry Credit addresses to their more user // friendly and human readable formats. // // Creates the binary form. Just needs the conversion to base58 // for display. func ConvertAddressToUser(prefix []byte, addr interfaces.IAddress) []byte { dat := prefix dat = append(dat, addr.Bytes()...) sha256d := Sha(Sha(dat).Bytes()).Bytes() userd := prefix userd = append(userd, addr.Bytes()...) userd = append(userd, sha256d[:4]...) return userd }
func (w *SCWallet) AddInput(trans interfaces.ITransaction, address interfaces.IAddress, amount uint64) error { // Check if this is an address we know. we, adr, err := w.getWalletEntry([]byte(constants.W_RCD_ADDRESS_HASH), address) // If it isn't, we assume the user knows what they are doing. if we == nil || err != nil { rcd := NewRCD_1(address.Bytes()) trans.AddRCD(rcd) adr, err := rcd.GetAddress() if err != nil { return err } trans.AddInput(CreateAddress(adr), amount) } else { trans.AddRCD(we.GetRCD()) trans.AddInput(CreateAddress(adr), amount) } return nil }
func (w *SCWallet) getWalletEntry(bucket []byte, address interfaces.IAddress) (interfaces.IWalletEntry, interfaces.IAddress, error) { v, err := w.db.Get([]byte(constants.W_RCD_ADDRESS_HASH), address.Bytes(), new(WalletEntry)) if err != nil { return nil, nil, err } if v == nil { return nil, nil, fmt.Errorf("Unknown address") } we := v.(*WalletEntry) adr, err := we.GetAddress() if err != nil { return nil, nil, err } return we, adr, nil }