From f851553c8c084f764c3f90edee8bfa2a0237835d Mon Sep 17 00:00:00 2001 From: shaojunda Date: Wed, 9 Dec 2020 19:33:57 +0800 Subject: [PATCH] feat: support custom SystemScripts BREAKING CHANGE: need send a SystemScripts to `GenerateTx` method manually --- payment/payment.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/payment/payment.go b/payment/payment.go index 8b6d2304..caf97c67 100644 --- a/payment/payment.go +++ b/payment/payment.go @@ -45,11 +45,11 @@ func NewPayment(from, to string, amount, fee uint64) (*Payment, error) { }, nil } -func (p *Payment) GenerateTx(client rpc.Client) (*types.Transaction, error) { - return generateTxWithIndexer(client, p) +func (p *Payment) GenerateTx(client rpc.Client, systemScripts *utils.SystemScripts) (*types.Transaction, error) { + return generateTxWithIndexer(client, p, systemScripts) } -func generateTxWithIndexer(client rpc.Client, p *Payment) (*types.Transaction, error) { +func generateTxWithIndexer(client rpc.Client, p *Payment, systemScripts *utils.SystemScripts) (*types.Transaction, error) { searchKey := &indexer.SearchKey{ Script: p.From, ScriptType: indexer.ScriptTypeLock, @@ -64,11 +64,6 @@ func generateTxWithIndexer(client rpc.Client, p *Payment) (*types.Transaction, e return nil, fmt.Errorf("insufficient balance: %d", result.Capacity) } - systemScripts, err := utils.NewSystemScripts(client) - if err != nil { - return nil, fmt.Errorf("load system script error: %v", err) - } - tx := transaction.NewSecp256k1SingleSigTx(systemScripts) tx.Outputs = append(tx.Outputs, &types.CellOutput{ Capacity: p.Amount,