1

I am wondering how to create the multisig accounts for stellar. I am using "py-stellar-base" SDK to send the transactions. Below is the code which sends the lumens from one address to other

from stellar_base.keypair import Keypair
from stellar_base.asset import Asset
from stellar_base.operation import Payment,SetOptions
from stellar_base.transaction import Transaction
from stellar_base.transaction_envelope import TransactionEnvelope as Te
from stellar_base.memo import TextMemo
from stellar_base.horizon import horizon_testnet, horizon_livenet

alice_public_key = 'GD2HPONSMOTEJQUE2WIUBPMWZ7WPAE7EBLW2RRD2XH6CIJHKCZKAYMZ3'
alice_seed = 'SCQUFZIFKMF3CYXAYKPKBQZRF33O3YKJMQXL63PVW7O66GBQOTVKR3A5'
bob_address = 'GCGUHPNOCTJVOC7YQUX6UG6L3S6PUPHNZJFEVSVSP56GJIC7OBCNXHUA'
amount = '10'

Alice = Keypair.from_seed(alice_seed)

horizon = horizon_testnet() # horizon = horizon_livenet() for LIVENET

# asset = Asset('CNY', CNY_ISSUER)
asset = Asset("XLM") 
# create op 
op = Payment({
    # 'source' : Alice.address().decode(),
    'destination': bob_address,
    'asset': asset,
    'amount': amount
})
msg = TextMemo('Buy yourself a beer !')

# get sequence of Alice
# Python 2
# sequence = horizon.account(Alice.address()).get('sequence')
# Python 3
sequence = horizon.account(Alice.address().decode('utf-8')).get('sequence')

# construct Tx
tx = Transaction(
    source = Alice.address().decode('utf-8'),
    opts = {
        'sequence': sequence,
        # 'timeBounds': [],
        'memo': msg,
        'fee': 100,
        'operations': [
            op
        ],
    },
)


# build envelope
envelope = Te(tx=tx, opts={"network_id": "TESTNET"}) # envelope = Te(tx=tx, opts={"network_id": "PUBLIC"}) for LIVENET
# sign 
envelope.sign(Alice)
sec = Keypair.from_seed(second_private_key)
envelope.sign(sec)
third = Keypair.from_seed(third_private_key)
envelope.sign(third)
# submit
xdr = envelope.xdr()
response = horizon.submit(xdr)

I can't get how to generate the multisig address and to create multisig account. Could anyone please help me out?

1

Not familiar with the Python SDK, but here is the basic idea:

Overview Let's create a multi-signature account between two parties, Alice and Bob. This will be a 2-of-2 multi-signature account, requiring each signer's signature to perform any action.

ACCOUNT CREATION TRANSACTION (need a source account with XLM and a generated public/private keypair)

Operations
1. Create Account w/ desired amount of XLM
 -- Sign with source account.
 -- Broadcast transaction.

MULTI-SIGNATURE SETUP TRANSACTION

Operations
1. Add signer Alice w/ weight 1
2. Add signer Bob w/ weight 1
3. Require each threshold to be weight 2
4. Set master key to weight 0
 -- Sign with master key of multi-signature account.
 -- Broadcast transaction.

Here are links to the important operations to be performed:

And here is a good place to read more about multi-signature accounts.

  • Hello Rob. master key of multi-signature account represents Alice or Bob seed? – merklexy Mar 12 '18 at 21:29
  • The master key of multi-signature is the key weight of the account itself -- while we are setting it up to be a multi-signature account, it starts as just a normal account meaning the multi-signature account is automatically a signer of itself. Every account has this... the master key of Alice is Alice, the master key of Bob is Bob, etc. Does this make sense? – Rob Mar 12 '18 at 21:39
  • It means, let's say Alice and Bob have a joint account. They want to send some lumens to Eve. At first, Alice has to sign the transaction and send the transaction object to the Bob to sign and then broadcast right. – merklexy Mar 12 '18 at 21:45
  • Yes, the transaction is invalid unless both sign it. – Rob Mar 12 '18 at 23:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.