@@ -26,7 +26,7 @@ class _MyAppState extends State<MyApp> {
2626 String displayText = "" ;
2727 ldk.SocketAddress ? bobAddr;
2828 ldk.Bolt11Invoice ? invoice;
29- ldk.UserChannelId ? userChannelId ;
29+ ldk.ChannelId ? channelId ;
3030
3131 // Replace this with your local esplora url
3232 String esploraUrl =
@@ -63,7 +63,7 @@ class _MyAppState extends State<MyApp> {
6363
6464 closeChannel () async {
6565 await aliceNode.closeChannel (
66- userChannelId : userChannelId ! , counterpartyNodeId: bobNodeId! );
66+ channelId : channelId ! , counterpartyNodeId: bobNodeId! );
6767 }
6868
6969 Future initAliceNode () async {
@@ -81,7 +81,7 @@ class _MyAppState extends State<MyApp> {
8181 final res = await aliceNode.nodeId ();
8282 setState (() {
8383 aliceNodeId = res;
84- displayText = "${aliceNodeId ?.hexCode } started successfully" ;
84+ displayText = "${aliceNodeId ?.hex } started successfully" ;
8585 });
8686 }
8787
@@ -113,16 +113,18 @@ class _MyAppState extends State<MyApp> {
113113 }
114114
115115 totalOnchainBalanceSats () async {
116- final alice = await aliceNode.listBalances ();
117- final bob = await bobNode.listBalances ();
116+ final alice = await aliceNode.totalOnchainBalanceSats ();
117+ final bob = await bobNode.totalOnchainBalanceSats ();
118118 if (kDebugMode) {
119- print ("alice's balance: ${alice .totalOnchainBalanceSats }" );
120- print ("alice's spendable balance: ${alice .spendableOnchainBalanceSats }" );
121- print ("bob's balance: ${bob .totalOnchainBalanceSats }" );
122- print ("bob's spendable balance: ${bob .spendableOnchainBalanceSats }" );
119+ print ("alice's balance: $alice " );
120+ print (
121+ "alice's spendable balance: ${await aliceNode .spendableOnchainBalanceSats ()}" );
122+ print ("bob's balance: $bob " );
123+ print (
124+ "bob's spendable balance: ${await bobNode .spendableOnchainBalanceSats ()}" );
123125 }
124126 setState (() {
125- aliceBalance = alice.spendableOnchainBalanceSats ;
127+ aliceBalance = alice;
126128 });
127129 }
128130
@@ -140,8 +142,7 @@ class _MyAppState extends State<MyApp> {
140142 if (res.isNotEmpty) {
141143 print ("======Channels========" );
142144 for (var e in res) {
143- print ("nodeId: ${aliceNodeId !.hexCode }" );
144- print ("userChannelId: ${e .userChannelId .data }" );
145+ print ("nodeId: ${aliceNodeId !.hex }" );
145146 print ("channelId: ${e .channelId .data }" );
146147 print ("isChannelReady: ${e .isChannelReady }" );
147148 print ("isUsable: ${e .isUsable }" );
@@ -211,10 +212,10 @@ class _MyAppState extends State<MyApp> {
211212 connectOpenChannel () async {
212213 final funding_amount_sat = 80000 ;
213214 final push_msat = (funding_amount_sat / 2 ) * 1000 ;
214- userChannelId = await aliceNode.connectOpenChannel (
215+ await aliceNode.connectOpenChannel (
215216 channelAmountSats: funding_amount_sat,
216217 announceChannel: true ,
217- address : bobAddr! ,
218+ socketAddress : bobAddr! ,
218219 pushToCounterpartyMsat: push_msat.toInt (),
219220 nodeId: bobNodeId! );
220221 }
@@ -232,6 +233,24 @@ class _MyAppState extends State<MyApp> {
232233 });
233234 }
234235
236+ setChannelId () async {
237+ final channelInfos = await aliceNode.listChannels ();
238+ if (channelInfos.isNotEmpty) {
239+ channelId = channelInfos.first.channelId;
240+ if (kDebugMode) {
241+ print (channelId? .data);
242+ }
243+
244+ setState (() {
245+ displayText = channelId! .data.toString ();
246+ });
247+ } else {
248+ if (kDebugMode) {
249+ print ("No open channels available" );
250+ }
251+ }
252+ }
253+
235254 stop () async {
236255 await bobNode.stop ();
237256 await aliceNode.stop ();
@@ -443,6 +462,20 @@ class _MyAppState extends State<MyApp> {
443462 fontSize: 12 ,
444463 height: 1.5 ,
445464 fontWeight: FontWeight .w800))),
465+ TextButton (
466+ onPressed: () async {
467+ await setChannelId ();
468+ },
469+ child: Text (
470+ 'Set channelId' ,
471+ overflow: TextOverflow .clip,
472+ textAlign: TextAlign .center,
473+ style: GoogleFonts .nunito (
474+ color: Colors .indigoAccent,
475+ fontSize: 12 ,
476+ height: 1.5 ,
477+ fontWeight: FontWeight .w800),
478+ )),
446479 TextButton (
447480 onPressed: () async {
448481 await receiveAndSendPayments ();
@@ -512,7 +545,7 @@ class _MyAppState extends State<MyApp> {
512545 Text (
513546 aliceNodeId == null
514547 ? "Node not initialized"
515- : "@Id_:${aliceNodeId !.hexCode }" ,
548+ : "@Id_:${aliceNodeId !.hex }" ,
516549 maxLines: 1 ,
517550 overflow: TextOverflow .ellipsis,
518551 textAlign: TextAlign .center,
0 commit comments