Skip to content

Instantly share code, notes, and snippets.

@johnthethird
Created March 19, 2022 05:19
Show Gist options
  • Save johnthethird/a1063b65274bb162b77959632cbe5b54 to your computer and use it in GitHub Desktop.
Save johnthethird/a1063b65274bb162b77959632cbe5b54 to your computer and use it in GitHub Desktop.
// FYI this will currently allow you to only import to the same addr you exported from
func (w *Wallet) buildExportTxC2P(srcAddr common.Address, amount uint64, amountPlusFee uint64, nonce uint64) (*evm.UnsignedExportTx, error) {
exportTx := &evm.UnsignedExportTx{
NetworkID: w.ChainConfig.NetworkID,
BlockchainID: w.ChainConfig.CChainID,
DestinationChain: ids.Empty,
Ins: []evm.EVMInput{
{
Address: srcAddr,
Amount: amountPlusFee,
AssetID: w.ChainConfig.AVAXAssetID,
Nonce: nonce,
},
},
ExportedOutputs: []*avax.TransferableOutput{
{
Asset: avax.Asset{ID: w.ChainConfig.AVAXAssetID},
Out: &secp256k1fx.TransferOutput{
Amt: amount,
OutputOwners: secp256k1fx.OutputOwners{
Threshold: uint32(1),
Addrs: []ids.ShortID{w.PublicKeyAvm().Address()},
},
},
},
},
}
err := exportTx.ExportedOutputs[0].Out.Verify()
return exportTx, err
}
@johnthethird
Copy link
Author

Github you suck. Who TF would indent code like that? Can I talk to the manager?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment