Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid memory address or nil pointer dereference error occurs in dao withdrawal transaction #216

Open
15168316096 opened this issue Oct 26, 2023 · 1 comment

Comments

@15168316096
Copy link

Bug Report

Invalid memory address or nil pointer dereference error occurs in dao withdrawal transaction is reported

Current Behavior

Expected Behavior

I expect developer can use this dao withdraw example normal

Environment

  • CKB version: ckb v111
  • Chain: /
  • Operating system: MacOS 12.1
  • Arch: x64
  • Installation: /

Additional context/Screenshots

This bug can reproduced by these steps:

func Test_WithdrawDaoExample(t *testing.T) {
   sender := "ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsq2qf8keemy2p5uu0g0gn8cd4ju23s5269qk8rg4r"
   depositOutPoint := &types.OutPoint{
   	TxHash: types.HexToHash("0xebfb7bff39985865c20bd5b6c0190e58298eb9e4b1ddb9daee16166bed658c40"),
   	Index:  0,
   }

   network := types.NetworkTest
   client, err := rpc.Dial("https://testnet.ckb.dev")
   if err != nil {
   	return
   }
   iterator, err := collector.NewLiveCellIteratorFromAddress(client, sender)
   if err != nil {
   	return
   }

   // build transaction
   builder, err := builder.NewDaoTransactionBuilder(network, iterator, depositOutPoint, client)
   if err != nil {
   	return
   }
   builder.FeeRate = 1000
   if err := builder.AddWithdrawOutput(sender); err != nil {
   	return
   }
   builder.AddChangeOutputByAddress(sender)

   withdrawInfo, err := handler.NewWithdrawInfo(client, depositOutPoint)
   if err != nil {
   	return
   }
   txWithGroups, err := builder.Build(withdrawInfo)
   if err != nil {
   	return
   }

   // sign transaction
   txSigner := signer.GetTransactionSignerInstance(network)
   _, err = txSigner.SignTransactionByPrivateKeys(txWithGroups, "0x6c9ed03816e3111e49384b8d180174ad08e29feb1393ea1b51cef1c505d4e36a")
   if err != nil {
   	return
   }

   // send transaction
   hash, err := client.SendTransaction(context.Background(), txWithGroups.TxView)
   if err != nil {
   	return
   }
   fmt.Println("transaction hash: " + hexutil.Encode(hash.Bytes()))
   return
}

=== RUN   Test_WithdrawDaoExample
--- FAIL: Test_WithdrawDaoExample (1.31s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
   panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x1002ec730]

goroutine 6 [running]:
testing.tRunner.func1.2({0x100345c40, 0x100614e70})
   /usr/local/go/src/testing/testing.go:1389 +0x24e
testing.tRunner.func1()
   /usr/local/go/src/testing/testing.go:1392 +0x39f
panic({0x100345c40, 0x100614e70})
   /usr/local/go/src/runtime/panic.go:838 +0x207
github.com/nervosnetwork/ckb-sdk-go/v2/collector/builder.NewDaoTransactionBuilder(0x100433740?, {0x100434fe8?, 0xc000076660}, 0xc000024990, {0x1004379d0, 0xc000010088})
   /Users/xueyanli/GolandProjects/ckb-sdk-go/collector/builder/dao.go:38 +0xd0
github.com/nervosnetwork/ckb-sdk-go/v2/collector/example.Test_WithdrawDaoExample(0x0?)
   /Users/xueyanli/GolandProjects/ckb-sdk-go/collector/example/example_test.go:321 +0x176
testing.tRunner(0xc000191a00, 0x1003d73a0)
   /usr/local/go/src/testing/testing.go:1439 +0x102
created by testing.(*T).Run
   /usr/local/go/src/testing/testing.go:1486 +0x35f


Process finished with the exit code 1
@15168316096
Copy link
Author

This is because the case uses the previously generated deposit cell, which should be combined with the case of deposit nevos dao to obtain a new deposit cell. Therefore, in order to ensure the stability of the case, this value cannot be hard-coded. The process of deposit nervos dao should be quoted first and then withdraw,
same as java sdk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant