forked from opensourcewebsite-org/php-stellar-sdk
-
Notifications
You must be signed in to change notification settings - Fork 1
/
add-signer.php
38 lines (24 loc) · 1.04 KB
/
add-signer.php
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
<?php
/**
* Adds a new signer to an existing account
*/
require '../vendor/autoload.php';
use \ZuluCrypto\StellarSdk\Keypair;
use \ZuluCrypto\StellarSdk\Server;
use \ZuluCrypto\StellarSdk\XdrModel\Operation\SetOptionsOp;
use \ZuluCrypto\StellarSdk\XdrModel\SignerKey;
use \ZuluCrypto\StellarSdk\XdrModel\Signer;
$server = Server::testNet();
// GB7H6NXC42ABH7C4IBQSYXKAFNAC4V4ZDNRXBVH6MKLIRB6YLXC7RWYD
$currentAccount = Keypair::newFromSeed('SD2MKS6CGVTFH7NJZFXQGXDQSDOLRLCRY7JN6WPULMJPCGBNLK4KU34R');
// GBD7ENB2PF6WFSKH6L6BBBMULSWL4XQPCA4CDLEMMNAK5RINHQO3H3GB
$newSigner = Keypair::newFromSeed('SB7X4LP4CS3YOFECRZFYOY63Q4GATOIDRWTUR3VQTLCIXY22OB45NHED');
$optionsOperation = new SetOptionsOp();
$optionsOperation->setMasterWeight(10);
$signerKey = SignerKey::fromKeypair($newSigner);
$newAccountSigner = new Signer($signerKey, 1);
$optionsOperation->updateSigner($newAccountSigner);
// Submit to the network
$server->buildTransaction($currentAccount->getPublicKey())
->addOperation($optionsOperation)
->submit($currentAccount->getSecret());