-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli-pay-address-multisig.sh
62 lines (49 loc) · 2.52 KB
/
cli-pay-address-multisig.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
set -euo pipefail
#--------- Import common paths and functions ---------
source common-utils.sh
#--------- Run program ---------
info "This program requires 2 witnesses to sign the transaction in order to spend the utxo"
info "List of Addresses" && ls -1 ${address_path}/*.addr
read -p "Insert origin 1 address (example payment1) : " wallet_origin1 && ${cardano_script_path}/cli-query-utxo.sh ${wallet_origin1}
read -p "Insert tx-in : " txIn1
read -p "Insert tx-in id : " txInId1
read -p "Insert origin 2 address (example payment2) : " wallet_origin2 && ${cardano_script_path}/cli-query-utxo.sh ${wallet_origin2}
read -p "Insert tx-in : " txIn2
read -p "Insert tx-in id : " txInId2
read -p "Insert wallet destination address to pay (example payment2) : " wallet_dest
read -p "Insert wallet change address (example payment1) : " wallet_change
read -p "Insert amount to send (example 500 ADA = 500,000,000 lovelace) : " amount
info "Building transaction \n Note: tx-in consumed from 2 origin addresses, and 1 txout to destination address"
${cardanocli} transaction build \
--babbage-era \
--tx-in "${txIn1}#${txInId1}" \
--tx-in "${txIn2}#${txInId2}" \
--tx-out $(cat ${address_path}/${wallet_dest}.addr)+${amount} \
--change-address $(cat ${address_path}/${wallet_change}.addr) \
--witness-override 2 \
--testnet-magic ${TESTNET_MAGIC} \
--out-file ${transaction_path}/multisig-tx.build
info "Signing transaction witness 1"
${cardanocli} transaction witness \
--tx-body-file ${transaction_path}/multisig-tx.build \
--signing-key-file ${key_path}/${wallet_origin1}.skey \
--testnet-magic ${TESTNET_MAGIC} \
--out-file ${transaction_path}/${wallet_origin1}.witness
info "Signing transaction witness 2"
${cardanocli} transaction witness \
--tx-body-file ${transaction_path}/multisig-tx.build \
--signing-key-file ${key_path}/${wallet_origin2}.skey \
--testnet-magic ${TESTNET_MAGIC} \
--out-file ${transaction_path}/${wallet_origin2}.witness
info "Assembling transaction witness 1 and 2"
${cardanocli} transaction assemble \
--tx-body-file ${transaction_path}/multisig-tx.build \
--witness-file ${transaction_path}/${wallet_origin1}.witness \
--witness-file ${transaction_path}/${wallet_origin2}.witness \
--out-file ${transaction_path}/multisig-tx.signed
info "Submiting transaction"
${cardanocli} transaction submit \
--tx-file ${transaction_path}/multisig-tx.signed \
--testnet-magic ${TESTNET_MAGIC}
info "Wait for ~20 seconds so the transaction is in the blockchain."