@@ -652,8 +652,8 @@ def authorizeChannelAccounts(primaryPubKey, channelAccPubKeys, primaryAccountSec
652652 )
653653
654654 transactionBuilder.append_set_options_op(
655- master_weight = 44 ,
656655 high_threshold = 44 ,
656+ master_weight = 44 ,
657657 medium_threshold = 3
658658 )
659659
@@ -664,22 +664,172 @@ def authorizeChannelAccounts(primaryPubKey, channelAccPubKeys, primaryAccountSec
664664 " weight" : 3
665665 }
666666 )
667-
668- transaction = transactionBuilder.build()
669- transaction.sign(primarySecretKey)
670- return server.submit_transaction(transaction)
671667```
672668
673669``` js
670+ const channelAccPubKeys = [
671+ " GA7WHVWBBUCVKVZ35GM5FVGZXZYJ63EFDB5VTFV2TRF4KLUXWN6CSIJL" ,
672+ " GD4EITS74V4RN5XOKO42DX2SRR3NI5JVC3LFUWIAVQH2PXBUEKLZU6V3" ,
673+ " GCEO3FNAOF7VKBRD22JHMT3Q5IVVUPDEICBKZNTKL7KUBOX6EDYYYTG4" ,
674+ " GAUTAZU2E6VUFOPRDOYAMYQBD7JU3XRLODSKLQL4EXIYUDB22FFPYDJC" ,
675+ " GBACJWSCHTRILBAPVOYXCVIFGUF7FSHTEKMITBI5ESCEQVEIJ6QFV4P5"
676+ ];
677+
678+ const primaryPubKey = " GC5AT5GU7WI5NHHRM4XH2ALBOQS5I2MTLNYH5RTEJZC5LWCKVN52SVBV" ;
679+ const primaryAccount = server .loadAccount (primaryPubKey);
680+
681+ async function generateChannelAccounts (primaryAccountSecret ) {
682+ const transactionBuilder = new StellarSdk.TransactionBuilder (primaryAccount, {
683+ fee: StellarSdk .BASE_FEE ,
684+ networkPassphrase: StellarSdk .Networks .TESTNET
685+ });
686+
687+ channelAccPubKeys .forEach (channelPubKey => {
688+ transactionBuilder .addOperation (StellarSdk .Operation .createAccount ({
689+ destination: channelPubKey,
690+ startingBalance: " 4.4"
691+ }));
692+ });
693+
694+ const transaction = transactionBuilder .build ();
695+ transaction .sign (primaryKeypair);
696+ const result = await server .submitTransaction (transaction);
697+ }
674698
699+ async function authorizeChannelAccounts (primaryAccountSecret ) {
700+ const transactionBuilder = new StellarSdk.TransactionBuilder (primaryAccount, {
701+ fee: StellarSdk .BASE_FEE ,
702+ networkPassphrase: StellarSdk .Networks .TESTNET
703+ });
704+
705+ transactionBuilder .addOperation (StellarSdk .Operation .setOptions ({
706+ highThreshold: 44 ,
707+ masterWeight: 44 ,
708+ mediumThreshold: 3
709+ }));
710+
711+ channelAccPubKeys .forEach (channelPubKey => {
712+ transactionBuilder .addOperation (StellarSdk .Operation .setOptions ({
713+ signer: {
714+ ed25519PublicKey: channelPubKey,
715+ weight: 3
716+ }
717+ }));
718+ });
719+ }
675720```
676721
677722``` java
723+ private static final List<String > channelAccPubKeys = Arrays . asList(
724+ " GA7WHVWBBUCVKVZ35GM5FVGZXZYJ63EFDB5VTFV2TRF4KLUXWN6CSIJL" ,
725+ " GD4EITS74V4RN5XOKO42DX2SRR3NI5JVC3LFUWIAVQH2PXBUEKLZU6V3" ,
726+ " GCEO3FNAOF7VKBRD22JHMT3Q5IVVUPDEICBKZNTKL7KUBOX6EDYYYTG4" ,
727+ " GAUTAZU2E6VUFOPRDOYAMYQBD7JU3XRLODSKLQL4EXIYUDB22FFPYDJC" ,
728+ " GBACJWSCHTRILBAPVOYXCVIFGUF7FSHTEKMITBI5ESCEQVEIJ6QFV4P5"
729+ );
730+ private static final String primaryPubKey = " GC5AT5GU7WI5NHHRM4XH2ALBOQS5I2MTLNYH5RTEJZC5LWCKVN52SVBV" ;
731+ private static final AccountResponse primaryAccount = server. accounts(). account(primaryPubKey);
678732
733+ public static void generateChannelAccounts(String primaryAccountSecret) throws Exception {
734+ Transaction . Builder transactionBuilder = new Transaction .Builder (primaryAccount, Network . TESTNET )
735+ .setBaseFee(Transaction . MIN_BASE_FEE )
736+
737+ for (String channelPubKeys : channelAccPubKeys) {
738+ transactionBuilder. addOperation(
739+ new CreateAccountOperation .Builder (channelPubKeys, startingBalance). build()
740+ );
741+ }
742+
743+ Transaction transaction = transactionBuilder. build();
744+ transaction. sign(primaryKeypair);
745+
746+ SubmitTransactionResponse response = server. submitTransaction(transaction);
747+ System . out. println(" Transaction successful: " + response);
748+ }
749+
750+ public static void authorizeChannelAccounts(String primaryAccountSecret) throws Exception {
751+
752+ Transaction . Builder transactionBuilder = new Transaction .Builder (primaryAccount, Network . TESTNET )
753+ .setBaseFee(Transaction . MIN_BASE_FEE )
754+
755+ transactionBuilder. addOperation(
756+ new SetOptionsOperation .Builder ()
757+ .setHighThreshold(44 )
758+ .setMasterKeyWeight(44 )
759+ .setMediumThreshold(3 )
760+ .build()
761+ );
762+
763+ for (String channelPubKeys : channelAccPubKeys) {
764+ transactionBuilder. addOperation(
765+ new SetOptionsOperation .Builder ()
766+ .setSigner(new Signer .SignerKeyEd25519 (channelPubKeys), 3 )
767+ .build()
768+ );
769+ }
770+ }
679771```
680772
681773``` go
774+ var (
775+ channelAccPubKeys = []string {
776+ " GA7WHVWBBUCVKVZ35GM5FVGZXZYJ63EFDB5VTFV2TRF4KLUXWN6CSIJL" ,
777+ " GD4EITS74V4RN5XOKO42DX2SRR3NI5JVC3LFUWIAVQH2PXBUEKLZU6V3" ,
778+ " GCEO3FNAOF7VKBRD22JHMT3Q5IVVUPDEICBKZNTKL7KUBOX6EDYYYTG4" ,
779+ " GAUTAZU2E6VUFOPRDOYAMYQBD7JU3XRLODSKLQL4EXIYUDB22FFPYDJC" ,
780+ " GBACJWSCHTRILBAPVOYXCVIFGUF7FSHTEKMITBI5ESCEQVEIJ6QFV4P5" ,
781+ }
782+ primaryPubKey = " GC5AT5GU7WI5NHHRM4XH2ALBOQS5I2MTLNYH5RTEJZC5LWCKVN52SVBV"
783+ )
682784
785+ func generateChannelAccounts (primaryAccountSecret string ) {
786+ tx , err := txnbuild.NewTransaction (
787+ txnbuild.TransactionParams {
788+ SourceAccount: &primaryAccount,
789+ IncrementSequenceNum: true ,
790+ BaseFee: txnbuild.MinBaseFee ,
791+ Operations: []txnbuild.Operation {},
792+ },
793+ )
794+ check (err)
795+
796+ for _ , channelPubKey := range channelAccPubKeys {
797+ createOp := txnbuild.CreateAccount {
798+ Destination: channelPubKey,
799+ Amount: " 4.4" ,
800+ }
801+ tx.Operations = append (tx.Operations , &createOp)
802+ }
803+ }
804+
805+ func authorizeChannelAccounts (primaryAccountSecret string ) {
806+ tx , err := txnbuild.NewTransaction (
807+ txnbuild.TransactionParams {
808+ SourceAccount: &primaryAccount,
809+ IncrementSequenceNum: true ,
810+ BaseFee: txnbuild.MinBaseFee ,
811+ Operations: []txnbuild.Operation {},
812+ },
813+ )
814+ check (err)
815+
816+ setThreshOp := txnbuild.SetOptions {
817+ HighThreshold: txnbuild.NewThreshold (44 ),
818+ MasterWeight: txnbuild.NewThreshold (44 ),
819+ MediumThreshold: txnbuild.NewThreshold (3 ),
820+ }
821+ tx.Operations = append (tx.Operations , &setThreshOp)
822+
823+ for _ , channelPubKey := range channelAccPubKeys {
824+ addSignerOp := txnbuild.SetOptions {
825+ Signer: &txnbuild.Signer {
826+ Address: channelPubKey,
827+ Weight: txnbuild.NewThreshold (3 )
828+ },
829+ }
830+ tx.Operations = append (tx.Operations , &addSignerOp)
831+ }
832+ }
683833```
684834
685835</CodeExample >
0 commit comments