Cosigning aggregate bonded transactions

How to cosign aggregate bonded transactions.

Prerequisites

Method #01: Using the Desktop Wallet

  1. Log in to a cosignatory account that has an impending aggregate bonded transaction waiting to be signed.
  2. At the home page, click on the “partial” tab. Click on the listed transaction and enter your wallet password to sign the transaction.
../../_images/add-signer-2.gif

Method #02: Using the SDK

  1. Create a function to cosign any AggregateBondedTransaction.
const cosignAggregateBondedTransaction = (transaction: AggregateTransaction, account: Account): CosignatureSignedTransaction => {
    const cosignatureTransaction = CosignatureTransaction.create(transaction);
    return account.signCosignatureTransaction(cosignatureTransaction);
};
const cosignAggregateBondedTransaction = (transaction, account) => {
    const cosignatureTransaction = symbol_sdk_1.CosignatureTransaction.create(transaction);
    return account.signCosignatureTransaction(cosignatureTransaction);
};
  1. Fetch all aggregate bonded transactions pending to be signed by your account.

Note

To fetch aggregate bonded transactions that must be signed by multisig cosignatories, refer to the multisig public key instead. See how to get multisig accounts where an account is cosignatory.

  1. For each transaction, check if you have not already signed it. Cosign each pending transaction using the previously created function.
  2. Announce CosignatureSignedTransaction to the network using the TransactionHttp repository.
// replace with network type
const networkType = NetworkType.TEST_NET;
// replace with private key
const privateKey = '0000000000000000000000000000000000000000000000000000000000000000';
const account = Account.createFromPrivateKey(privateKey, networkType);
// replace with node endpoint
const nodeUrl = 'http://api-01.ap-northeast-1.testnet-0951-v1.symboldev.network:3000';
const repositoryFactory = new RepositoryFactoryHttp(nodeUrl);
const transactionHttp = repositoryFactory.createTransactionRepository();
const accountHttp = repositoryFactory.createAccountRepository();

accountHttp
    .getAccountPartialTransactions(account.address)
    .pipe(
        mergeMap((_) => _),
        filter((_) => !_.signedByAccount(account.publicAccount)),
        map((transaction) => cosignAggregateBondedTransaction(transaction, account)),
        mergeMap((cosignatureSignedTransaction) =>
            transactionHttp.announceAggregateBondedCosignature(cosignatureSignedTransaction)),
    )
    .subscribe((announcedTransaction) => console.log(announcedTransaction),
        (err) => console.error(err));
// replace with network type
const networkType = symbol_sdk_1.NetworkType.TEST_NET;
// replace with private key
const privateKey = '0000000000000000000000000000000000000000000000000000000000000000';
const account = symbol_sdk_1.Account.createFromPrivateKey(privateKey, networkType);
// replace with node endpoint
const nodeUrl = 'http://api-01.ap-northeast-1.testnet-0951-v1.symboldev.network:3000';
const repositoryFactory = new symbol_sdk_1.RepositoryFactoryHttp(nodeUrl);
const transactionHttp = repositoryFactory.createTransactionRepository();
const accountHttp = repositoryFactory.createAccountRepository();
accountHttp
    .getAccountPartialTransactions(account.address)
    .pipe(operators_1.mergeMap((_) => _), operators_1.filter((_) => !_.signedByAccount(account.publicAccount)), operators_1.map((transaction) => cosignAggregateBondedTransaction(transaction, account)), operators_1.mergeMap((cosignatureSignedTransaction) => transactionHttp.announceAggregateBondedCosignature(cosignatureSignedTransaction)))
    .subscribe((announcedTransaction) => console.log(announcedTransaction), (err) => console.error(err));

Method #03: Using the CLI

symbol-cli transaction cosign --hash A6A374E66B32A3D5133018EFA9CD6E3169C8EEA339F7CCBE29C47D07086E068C