diff --git a/pkg/rpcclient/actor/actor.go b/pkg/rpcclient/actor/actor.go index 2884c3cd2..89b9a1d2a 100644 --- a/pkg/rpcclient/actor/actor.go +++ b/pkg/rpcclient/actor/actor.go @@ -280,6 +280,19 @@ func (a *Actor) SendUncheckedRun(script []byte, sysfee int64, attrs []transactio return a.sendWrapper(a.MakeUncheckedRun(script, sysfee, attrs, txHook)) } +// SignerAccounts returns the array of actor's signers/accounts. It's useful in +// case you need it elsewhere like for notary-related processing. Returned slice +// is a newly allocated one with signers deeply copied, accounts however are not +// so changing received account internals is an error. +func (a *Actor) SignerAccounts() []SignerAccount { + var res = make([]SignerAccount, len(a.signers)) + for i := range a.signers { + res[i].Signer = *a.signers[i].Signer.Copy() + res[i].Account = a.signers[i].Account + } + return res +} + // Sender return the sender address that will be used in transactions created // by Actor. func (a *Actor) Sender() util.Uint160 { diff --git a/pkg/rpcclient/actor/actor_test.go b/pkg/rpcclient/actor/actor_test.go index 4bd1b98a8..1dc120129 100644 --- a/pkg/rpcclient/actor/actor_test.go +++ b/pkg/rpcclient/actor/actor_test.go @@ -101,9 +101,14 @@ func TestNew(t *testing.T) { // Good simple. a, err := NewSimple(client, acc) require.NoError(t, err) - require.Equal(t, 1, len(a.signers)) + require.Equal(t, []SignerAccount{{ + Signer: transaction.Signer{ + Account: acc.ScriptHash(), + Scopes: transaction.CalledByEntry, + }, + Account: acc, + }}, a.SignerAccounts()) require.Equal(t, 1, len(a.txSigners)) - require.Equal(t, transaction.CalledByEntry, a.signers[0].Signer.Scopes) require.Equal(t, transaction.CalledByEntry, a.txSigners[0].Scopes) // Contractless account. @@ -158,7 +163,7 @@ func TestNew(t *testing.T) { signers[0].Signer.Account = acc.Contract.ScriptHash() a, err = New(client, signers) require.NoError(t, err) - require.Equal(t, 2, len(a.signers)) + require.Equal(t, signers, a.SignerAccounts()) require.Equal(t, 2, len(a.txSigners)) // Good tuned