Skip to content

Commit 739aec6

Browse files
tamirmsclaude
andcommitted
Fix SetOpSourceAccount silently ignoring invalid source account errors
SetOpSourceAccount was discarding the error returned by MuxedAccount.SetAddress, which could produce a partially initialized MuxedAccount that panics on subsequent Address() calls. Return the error instead and check it in all 27 BuildXDR callers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent fa15bc7 commit 739aec6

28 files changed

Lines changed: 89 additions & 30 deletions

txnbuild/account_merge.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ func (am *AccountMerge) BuildXDR() (xdr.Operation, error) {
2626
return xdr.Operation{}, errors.Wrap(err, "failed to build XDR OperationBody")
2727
}
2828
op := xdr.Operation{Body: body}
29-
SetOpSourceAccount(&op, am.SourceAccount)
29+
if err = SetOpSourceAccount(&op, am.SourceAccount); err != nil {
30+
return xdr.Operation{}, err
31+
}
3032
return op, nil
3133
}
3234

txnbuild/allow_trust.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ func (at *AllowTrust) BuildXDR() (xdr.Operation, error) {
5656
return xdr.Operation{}, errors.Wrap(err, "failed to build XDR OperationBody")
5757
}
5858
op := xdr.Operation{Body: body}
59-
SetOpSourceAccount(&op, at.SourceAccount)
59+
if err = SetOpSourceAccount(&op, at.SourceAccount); err != nil {
60+
return xdr.Operation{}, err
61+
}
6062
return op, nil
6163
}
6264

txnbuild/begin_sponsoring_future_reserves.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ func (bs *BeginSponsoringFutureReserves) BuildXDR() (xdr.Operation, error) {
2727
return xdr.Operation{}, errors.Wrap(err, "failed to build XDR OperationBody")
2828
}
2929
op := xdr.Operation{Body: body}
30-
SetOpSourceAccount(&op, bs.SourceAccount)
30+
if err = SetOpSourceAccount(&op, bs.SourceAccount); err != nil {
31+
return xdr.Operation{}, err
32+
}
3133
return op, nil
3234
}
3335

txnbuild/bump_sequence.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ func (bs *BumpSequence) BuildXDR() (xdr.Operation, error) {
2121
return xdr.Operation{}, errors.Wrap(err, "failed to build XDR OperationBody")
2222
}
2323
op := xdr.Operation{Body: body}
24-
SetOpSourceAccount(&op, bs.SourceAccount)
24+
if err = SetOpSourceAccount(&op, bs.SourceAccount); err != nil {
25+
return xdr.Operation{}, err
26+
}
2527
return op, nil
2628
}
2729

txnbuild/change_trust.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ func (ct *ChangeTrust) BuildXDR() (xdr.Operation, error) {
5858
return xdr.Operation{}, errors.Wrap(err, "failed to build XDR OperationBody")
5959
}
6060
op := xdr.Operation{Body: body}
61-
SetOpSourceAccount(&op, ct.SourceAccount)
61+
if err = SetOpSourceAccount(&op, ct.SourceAccount); err != nil {
62+
return xdr.Operation{}, err
63+
}
6264
return op, nil
6365
}
6466

txnbuild/claim_claimable_balance.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ func (cb *ClaimClaimableBalance) BuildXDR() (xdr.Operation, error) {
3131
return xdr.Operation{}, errors.Wrap(err, "failed to build XDR OperationBody")
3232
}
3333
op := xdr.Operation{Body: body}
34-
SetOpSourceAccount(&op, cb.SourceAccount)
34+
if err = SetOpSourceAccount(&op, cb.SourceAccount); err != nil {
35+
return xdr.Operation{}, err
36+
}
3537

3638
return op, nil
3739
}

txnbuild/clawback.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ func (cb *Clawback) BuildXDR() (xdr.Operation, error) {
5454
return xdr.Operation{}, errors.Wrap(err, "failed to build XDR Operation")
5555
}
5656
op := xdr.Operation{Body: body}
57-
SetOpSourceAccount(&op, cb.SourceAccount)
57+
if err = SetOpSourceAccount(&op, cb.SourceAccount); err != nil {
58+
return xdr.Operation{}, err
59+
}
5860
return op, nil
5961
}
6062

txnbuild/clawback_claimable_balance.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ func (cb *ClawbackClaimableBalance) BuildXDR() (xdr.Operation, error) {
3030
return xdr.Operation{}, errors.Wrap(err, "failed to build XDR OperationBody")
3131
}
3232
op := xdr.Operation{Body: body}
33-
SetOpSourceAccount(&op, cb.SourceAccount)
33+
if err = SetOpSourceAccount(&op, cb.SourceAccount); err != nil {
34+
return xdr.Operation{}, err
35+
}
3436

3537
return op, nil
3638
}

txnbuild/create_account.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ func (ca *CreateAccount) BuildXDR() (xdr.Operation, error) {
3434
return xdr.Operation{}, errors.Wrap(err, "failed to build XDR OperationBody")
3535
}
3636
op := xdr.Operation{Body: body}
37-
SetOpSourceAccount(&op, ca.SourceAccount)
37+
if err = SetOpSourceAccount(&op, ca.SourceAccount); err != nil {
38+
return xdr.Operation{}, err
39+
}
3840

3941
return op, nil
4042
}

txnbuild/create_claimable_balance.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ func (cb *CreateClaimableBalance) BuildXDR() (xdr.Operation, error) {
134134
return xdr.Operation{}, errors.Wrap(err, "failed to build XDR OperationBody")
135135
}
136136
op := xdr.Operation{Body: body}
137-
SetOpSourceAccount(&op, cb.SourceAccount)
137+
if err = SetOpSourceAccount(&op, cb.SourceAccount); err != nil {
138+
return xdr.Operation{}, err
139+
}
138140
return op, nil
139141
}
140142

0 commit comments

Comments
 (0)