Exemple #1
0
func extractEnvelopeInfo(ctx context.Context, env string, passphrase string) (result envelopeInfo, err error) {
	var tx xdr.TransactionEnvelope

	err = xdr.SafeUnmarshalBase64(env, &tx)

	if err != nil {
		err = &MalformedTransactionError{env}
		return
	}

	txb := build.TransactionBuilder{TX: &tx.Tx}
	txb.Mutate(build.Network{passphrase})

	result.Hash, err = txb.HashHex()
	if err != nil {
		return
	}

	result.Sequence = uint64(tx.Tx.SeqNum)

	aid := tx.Tx.SourceAccount.MustEd25519()
	result.SourceAddress, err = strkey.Encode(strkey.VersionByteAccountID, aid[:])

	return
}
Exemple #2
0
// FromRawSeed creates a new keypair from the provided raw ED25519 seed:w
func FromRawSeed(rawSeed [32]byte) (KP, error) {
	seed, err := strkey.Encode(strkey.VersionByteSeed, rawSeed[:])
	if err != nil {
		return nil, err
	}

	return &Full{seed}, nil
}