Skip to content

Commit

Permalink
Allow sending to notary IDs as aux_dest when doing exportto tx
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeltout committed Dec 8, 2023
1 parent 579de01 commit 85afb7b
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions src/utils/api/channels/vrpc/requests/preflight.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,15 +389,30 @@ export const preflightCurrencyTransfer = async (coinObj, channelId, activeUser,
if (transDest.transfer_destination.gateway_id !== exportto) throw new Error("Expected gateway_id to match exportto");
if (transDest.transfer_destination.gateway_code !== "i3UXS5QPRQGNRDDqVnyWTnmFCTHDbzmsYk") throw new Error("Expected null gateway_code");
if (!transDest.transfer_destination.hasAuxDests()) throw new Error("Expected output with aux dests");
for (const aux_dest of transDest.transfer_destination.aux_dests) {
if (aux_dest.hasAuxDests()) {
throw new Error("Nested aux destinations not supported");

if (transDest.transfer_destination.aux_dests.length > 0) {
const selfSystemRes = await getCurrency(systemId, systemId);
if (selfSystemRes.error) throw new Error("Couldn't get own system information")

const permittedAuxDests = selfSystemRes.result.notaries != null && exportto != null ? selfSystemRes.result.notaries : []

for (const aux_dest of transDest.transfer_destination.aux_dests) {
if (aux_dest.hasAuxDests()) {
throw new Error("Nested aux destinations not supported");
}

if (aux_dest.isGateway()) throw new Error("Expected non gateway output in aux dest");

const addrString = aux_dest.getAddressString();
if (
addrString !== addrDest &&
addrString !== source &&
!(permittedAuxDests.includes(addrString) && aux_dest.isIAddr())
)
throw new Error(
`Aux dest ${addrString} does not match source or destination`,
);
}

if (aux_dest.isGateway()) throw new Error("Expected non gateway output in aux dest");

const addrString =aux_dest.getAddressString();
if (addrString !== addrDest && addrString !== source) throw new Error(`Aux dest ${addrString} does not match source or destination`);
}
}

Expand Down

0 comments on commit 85afb7b

Please sign in to comment.