@@ -892,7 +892,7 @@ static void cleanup_test_wallet(struct wallet *w, char *filename)
892892 tal_free (filename );
893893}
894894
895- static struct wallet * create_test_wallet (struct lightningd * ld , const tal_t * ctx )
895+ static struct wallet * create_test_wallet (struct lightningd * ld , const tal_t * ctx , bool bip86 )
896896{
897897 char * dsn , * filename ;
898898 int fd = tmpdir_mkstemp (ctx , "ldb-XXXXXX" , & filename );
@@ -911,11 +911,16 @@ static struct wallet *create_test_wallet(struct lightningd *ld, const tal_t *ctx
911911 w -> ld = ld ;
912912 ld -> wallet = w ;
913913
914- ld -> bip86_base = NULL ;
915914 ld -> bip32_base = tal (ld , struct ext_key );
916915 CHECK (bip32_key_from_seed (badseed , sizeof (badseed ),
917916 BIP32_VER_TEST_PRIVATE , 0 ,
918917 ld -> bip32_base ) == WALLY_OK );
918+ if (bip86 ) {
919+ ld -> bip86_base = ld -> bip32_base ;
920+ ld -> bip32_base = NULL ;
921+ } else {
922+ ld -> bip86_base = NULL ;
923+ }
919924
920925 CHECK_MSG (w -> db , "Failed opening the db" );
921926 w -> db -> data_version = 0 ;
@@ -933,9 +938,9 @@ static struct wallet *create_test_wallet(struct lightningd *ld, const tal_t *ctx
933938 return w ;
934939}
935940
936- static bool test_wallet_outputs (struct lightningd * ld , const tal_t * ctx )
941+ static bool test_wallet_outputs (struct lightningd * ld , const tal_t * ctx , bool bip86 )
937942{
938- struct wallet * w = create_test_wallet (ld , ctx );
943+ struct wallet * w = create_test_wallet (ld , ctx , bip86 );
939944 struct utxo u ;
940945 struct pubkey pk ;
941946 struct node_id id ;
@@ -1145,10 +1150,10 @@ static bool test_wallet_outputs(struct lightningd *ld, const tal_t *ctx)
11451150 return true;
11461151}
11471152
1148- static bool test_shachain_crud (struct lightningd * ld , const tal_t * ctx )
1153+ static bool test_shachain_crud (struct lightningd * ld , const tal_t * ctx , bool bip86 )
11491154{
11501155 struct wallet_shachain a , b ;
1151- struct wallet * w = create_test_wallet (ld , ctx );
1156+ struct wallet * w = create_test_wallet (ld , ctx , bip86 );
11521157 struct sha256 seed , hash ;
11531158 struct secret secret ;
11541159 uint64_t index = UINT64_MAX >> (64 - SHACHAIN_BITS );
@@ -1344,9 +1349,9 @@ static struct channel *wallet_channel_load(struct wallet *w, const u64 dbid)
13441349 return channel ;
13451350}
13461351
1347- static bool test_channel_crud (struct lightningd * ld , const tal_t * ctx )
1352+ static bool test_channel_crud (struct lightningd * ld , const tal_t * ctx , bool bip86 )
13481353{
1349- struct wallet * w = create_test_wallet (ld , ctx );
1354+ struct wallet * w = create_test_wallet (ld , ctx , bip86 );
13501355 struct channel c1 , * c2 = tal (w , struct channel );
13511356 struct wireaddr_internal addr ;
13521357 struct peer * p ;
@@ -1526,9 +1531,9 @@ static int count_inflights(struct wallet *w, u64 channel_dbid)
15261531 return count ;
15271532}
15281533
1529- static bool test_channel_inflight_crud (struct lightningd * ld , const tal_t * ctx )
1534+ static bool test_channel_inflight_crud (struct lightningd * ld , const tal_t * ctx , bool bip86 )
15301535{
1531- struct wallet * w = create_test_wallet (ld , ctx );
1536+ struct wallet * w = create_test_wallet (ld , ctx , bip86 );
15321537 struct channel * chan , * c2 ;
15331538 struct channel_inflight * inflight ;
15341539 struct bitcoin_outpoint outpoint ;
@@ -1720,11 +1725,11 @@ static bool test_channel_inflight_crud(struct lightningd *ld, const tal_t *ctx)
17201725 return true;
17211726}
17221727
1723- static bool test_channel_config_crud (struct lightningd * ld , const tal_t * ctx )
1728+ static bool test_channel_config_crud (struct lightningd * ld , const tal_t * ctx , bool bip86 )
17241729{
17251730 struct channel_config * cc1 = talz (ctx , struct channel_config ),
17261731 * cc2 = talz (ctx , struct channel_config );
1727- struct wallet * w = create_test_wallet (ld , ctx );
1732+ struct wallet * w = create_test_wallet (ld , ctx , bip86 );
17281733 CHECK (w );
17291734
17301735 cc1 -> dust_limit .satoshis = 1 ;
@@ -1745,15 +1750,15 @@ static bool test_channel_config_crud(struct lightningd *ld, const tal_t *ctx)
17451750 return true;
17461751}
17471752
1748- static bool test_htlc_crud (struct lightningd * ld , const tal_t * ctx )
1753+ static bool test_htlc_crud (struct lightningd * ld , const tal_t * ctx , bool bip86 )
17491754{
17501755 struct db_stmt * stmt ;
17511756 struct htlc_in in , in2 , * hin ;
17521757 struct htlc_out out , out2 , * hout ;
17531758 struct preimage payment_key ;
17541759 struct channel * chan = tal (ctx , struct channel );
17551760 struct peer * peer = talz (ctx , struct peer );
1756- struct wallet * w = create_test_wallet (ld , ctx );
1761+ struct wallet * w = create_test_wallet (ld , ctx , bip86 );
17571762 struct htlc_in_map * htlcs_in = tal (ctx , struct htlc_in_map ), * rem ;
17581763 struct htlc_out_map * htlcs_out = tal (ctx , struct htlc_out_map );
17591764 struct onionreply * onionreply ;
@@ -1861,10 +1866,10 @@ static bool test_htlc_crud(struct lightningd *ld, const tal_t *ctx)
18611866 return true;
18621867}
18631868
1864- static bool test_payment_crud (struct lightningd * ld , const tal_t * ctx )
1869+ static bool test_payment_crud (struct lightningd * ld , const tal_t * ctx , bool bip86 )
18651870{
18661871 struct wallet_payment * t , * t2 ;
1867- struct wallet * w = create_test_wallet (ld , ctx );
1872+ struct wallet * w = create_test_wallet (ld , ctx , bip86 );
18681873 struct sha256 payment_hash ;
18691874 struct node_id destination ;
18701875
@@ -1967,15 +1972,17 @@ int main(int argc, const char *argv[])
19671972
19681973 /* We do a runtime test here, so we still check compile! */
19691974 if (HAVE_SQLITE3 ) {
1970- ok &= test_shachain_crud (ld , tmpctx );
1971- ok &= test_channel_crud (ld , tmpctx );
1972- ok &= test_channel_inflight_crud (ld , tmpctx );
1973- ok &= test_channel_config_crud (ld , tmpctx );
1974- ok &= test_channel_inflight_crud (ld , tmpctx );
1975- ok &= test_wallet_outputs (ld , tmpctx );
1976- ok &= test_htlc_crud (ld , tmpctx );
1977- ok &= test_payment_crud (ld , tmpctx );
1978- ok &= test_wallet_payment_status_enum ();
1975+ for (int bip86 = 0 ; bip86 < 2 ; bip86 ++ ) {
1976+ ok &= test_shachain_crud (ld , tmpctx , bip86 );
1977+ ok &= test_channel_crud (ld , tmpctx , bip86 );
1978+ ok &= test_channel_inflight_crud (ld , tmpctx , bip86 );
1979+ ok &= test_channel_config_crud (ld , tmpctx , bip86 );
1980+ ok &= test_channel_inflight_crud (ld , tmpctx , bip86 );
1981+ ok &= test_wallet_outputs (ld , tmpctx , bip86 );
1982+ ok &= test_htlc_crud (ld , tmpctx , bip86 );
1983+ ok &= test_payment_crud (ld , tmpctx , bip86 );
1984+ ok &= test_wallet_payment_status_enum ();
1985+ }
19791986 }
19801987
19811988 /* Do not clean up in the case of an error, we might want to debug the
0 commit comments