@@ -23,24 +23,32 @@ use super::{
2323 OffchainTransactionDependencyProvider ,
2424} ;
2525use crate :: rpc:: ckb_indexer:: { Order , SearchKey , Tip } ;
26- use crate :: rpc:: { CkbRpcAsyncClient , IndexerRpcAsyncClient } ;
27- use crate :: traits:: {
28- CellCollector , CellCollectorError , CellDepResolver , CellQueryOptions , HeaderDepResolver ,
29- LiveCell , QueryOrder , Signer , SignerError , TransactionDependencyError ,
30- TransactionDependencyProvider ,
31- } ;
32- use crate :: types:: ScriptId ;
3326use crate :: util:: { get_max_mature_number_async, serialize_signature, zeroize_privkey} ;
3427use crate :: SECP256K1 ;
28+ use crate :: {
29+ constants:: GENESIS_BLOCK_HASH_MAINNET ,
30+ rpc:: { CkbRpcAsyncClient , IndexerRpcAsyncClient } ,
31+ } ;
32+ use crate :: { constants:: MULTISIG_SCRIPT , types:: ScriptId } ;
3533use crate :: {
3634 constants:: {
37- DAO_OUTPUT_LOC , DAO_TYPE_HASH , MULTISIG_GROUP_OUTPUT_LOC , MULTISIG_OUTPUT_LOC ,
38- MULTISIG_TYPE_HASH , SIGHASH_GROUP_OUTPUT_LOC , SIGHASH_OUTPUT_LOC , SIGHASH_TYPE_HASH ,
35+ DAO_OUTPUT_LOC , DAO_TYPE_HASH , SIGHASH_GROUP_OUTPUT_LOC , SIGHASH_OUTPUT_LOC ,
36+ SIGHASH_TYPE_HASH ,
3937 } ,
4038 util:: keccak160,
4139} ;
40+ use crate :: {
41+ constants:: {
42+ GENESIS_BLOCK_HASH_TESTNET , MULTISIG_DEP_GROUP_MAINNET , MULTISIG_DEP_GROUP_TESTNET ,
43+ } ,
44+ traits:: {
45+ CellCollector , CellCollectorError , CellDepResolver , CellQueryOptions , HeaderDepResolver ,
46+ LiveCell , QueryOrder , Signer , SignerError , TransactionDependencyError ,
47+ TransactionDependencyProvider ,
48+ } ,
49+ } ;
4250use ckb_resource:: {
43- CODE_HASH_DAO , CODE_HASH_SECP256K1_BLAKE160_MULTISIG_ALL ,
51+ CODE_HASH_DAO , // CODE_HASH_SECP256K1_BLAKE160_MULTISIG_ALL,
4452 CODE_HASH_SECP256K1_BLAKE160_SIGHASH_ALL ,
4553} ;
4654
@@ -69,7 +77,7 @@ impl DefaultCellDepResolver {
6977 return Err ( ParseGenesisInfoError :: InvalidBlockNumber ( header. number ( ) ) ) ;
7078 }
7179 let mut sighash_type_hash = None ;
72- let mut multisig_type_hash = None ;
80+ // let mut multisig_type_hash = None;
7381 let mut dao_type_hash = None ;
7482 let out_points = genesis_block
7583 . transactions ( )
@@ -95,20 +103,20 @@ impl DefaultCellDepResolver {
95103 ) ;
96104 }
97105 }
98- if tx_index == MULTISIG_OUTPUT_LOC . 0 && index == MULTISIG_OUTPUT_LOC . 1 {
99- multisig_type_hash = output
100- . type_ ( )
101- . to_opt ( )
102- . map ( |script| script. calc_script_hash ( ) ) ;
103- let data_hash = CellOutput :: calc_data_hash ( & data. raw_data ( ) ) ;
104- if data_hash != CODE_HASH_SECP256K1_BLAKE160_MULTISIG_ALL . pack ( ) {
105- log:: error!(
106- "System multisig script code hash error! found: {}, expected: {}" ,
107- data_hash,
108- CODE_HASH_SECP256K1_BLAKE160_MULTISIG_ALL ,
109- ) ;
110- }
111- }
106+ // if tx_index == MULTISIG_OUTPUT_LOC.0 && index == MULTISIG_OUTPUT_LOC.1 {
107+ // multisig_type_hash = output
108+ // .type_()
109+ // .to_opt()
110+ // .map(|script| script.calc_script_hash());
111+ // let data_hash = CellOutput::calc_data_hash(&data.raw_data());
112+ // if data_hash != CODE_HASH_SECP256K1_BLAKE160_MULTISIG_ALL.pack() {
113+ // log::error!(
114+ // "System multisig script code hash error! found: {}, expected: {}",
115+ // data_hash,
116+ // CODE_HASH_SECP256K1_BLAKE160_MULTISIG_ALL,
117+ // );
118+ // }
119+ // }
112120 if tx_index == DAO_OUTPUT_LOC . 0 && index == DAO_OUTPUT_LOC . 1 {
113121 dao_type_hash = output
114122 . type_ ( )
@@ -132,9 +140,6 @@ impl DefaultCellDepResolver {
132140 let sighash_type_hash = sighash_type_hash
133141 . ok_or_else ( || "No type hash(sighash) found in txs[0][1]" . to_owned ( ) )
134142 . map_err ( ParseGenesisInfoError :: TypeHashNotFound ) ?;
135- let multisig_type_hash = multisig_type_hash
136- . ok_or_else ( || "No type hash(multisig) found in txs[0][4]" . to_owned ( ) )
137- . map_err ( ParseGenesisInfoError :: TypeHashNotFound ) ?;
138143 let dao_type_hash = dao_type_hash
139144 . ok_or_else ( || "No type hash(dao) found in txs[0][2]" . to_owned ( ) )
140145 . map_err ( ParseGenesisInfoError :: TypeHashNotFound ) ?;
@@ -143,10 +148,34 @@ impl DefaultCellDepResolver {
143148 . out_point ( out_points[ SIGHASH_GROUP_OUTPUT_LOC . 0 ] [ SIGHASH_GROUP_OUTPUT_LOC . 1 ] . clone ( ) )
144149 . dep_type ( DepType :: DepGroup . into ( ) )
145150 . build ( ) ;
146- let multisig_dep = CellDep :: new_builder ( )
147- . out_point ( out_points[ MULTISIG_GROUP_OUTPUT_LOC . 0 ] [ MULTISIG_GROUP_OUTPUT_LOC . 1 ] . clone ( ) )
148- . dep_type ( DepType :: DepGroup . into ( ) )
149- . build ( ) ;
151+
152+ let multisig_dep = if genesis_block. hash ( ) . eq ( & GENESIS_BLOCK_HASH_MAINNET . pack ( ) ) {
153+ // mainnet
154+ CellDep :: new_builder ( )
155+ . out_point (
156+ ckb_types:: packed:: OutPoint :: new_builder ( )
157+ . tx_hash ( MULTISIG_DEP_GROUP_MAINNET . 0 . pack ( ) )
158+ . index ( MULTISIG_DEP_GROUP_MAINNET . 1 . pack ( ) )
159+ . build ( ) ,
160+ )
161+ . dep_type ( DepType :: DepGroup . into ( ) )
162+ . build ( )
163+ } else if genesis_block. hash ( ) . eq ( & GENESIS_BLOCK_HASH_TESTNET . pack ( ) ) {
164+ // testnet
165+ CellDep :: new_builder ( )
166+ . out_point (
167+ ckb_types:: packed:: OutPoint :: new_builder ( )
168+ . tx_hash ( MULTISIG_DEP_GROUP_TESTNET . 0 . pack ( ) )
169+ . index ( MULTISIG_DEP_GROUP_TESTNET . 1 . pack ( ) )
170+ . build ( ) ,
171+ )
172+ . dep_type ( DepType :: DepGroup . into ( ) )
173+ . build ( )
174+ } else {
175+ //dev net
176+ unimplemented ! ( )
177+ } ;
178+
150179 let dao_dep = CellDep :: new_builder ( )
151180 . out_point ( out_points[ DAO_OUTPUT_LOC . 0 ] [ DAO_OUTPUT_LOC . 1 ] . clone ( ) )
152181 . build ( ) ;
@@ -157,7 +186,7 @@ impl DefaultCellDepResolver {
157186 ( sighash_dep, "Secp256k1 blake160 sighash all" . to_string ( ) ) ,
158187 ) ;
159188 items. insert (
160- ScriptId :: new_type ( multisig_type_hash . unpack ( ) ) ,
189+ MULTISIG_SCRIPT ,
161190 ( multisig_dep, "Secp256k1 blake160 multisig all" . to_string ( ) ) ,
162191 ) ;
163192 items. insert (
@@ -188,7 +217,7 @@ impl DefaultCellDepResolver {
188217 self . get ( & ScriptId :: new_type ( SIGHASH_TYPE_HASH ) )
189218 }
190219 pub fn multisig_dep ( & self ) -> Option < & ( CellDep , String ) > {
191- self . get ( & ScriptId :: new_type ( MULTISIG_TYPE_HASH ) )
220+ self . get ( & MULTISIG_SCRIPT )
192221 }
193222 pub fn dao_dep ( & self ) -> Option < & ( CellDep , String ) > {
194223 self . get ( & ScriptId :: new_type ( DAO_TYPE_HASH ) )
0 commit comments