@@ -457,10 +457,9 @@ class HTTP extends Server {
457
457
// Send TX
458
458
this . post ( '/wallet/:id/send' , async ( req , res ) => {
459
459
const valid = Validator . fromRequest ( req ) ;
460
- const passphrase = valid . str ( 'passphrase' ) ;
461
460
462
461
const options = TransactionOptions . fromValidator ( valid ) ;
463
- const tx = await req . wallet . send ( options , passphrase ) ;
462
+ const tx = await req . wallet . send ( options ) ;
464
463
465
464
const details = await req . wallet . getDetails ( tx . hash ( ) ) ;
466
465
@@ -470,14 +469,15 @@ class HTTP extends Server {
470
469
// Create TX
471
470
this . post ( '/wallet/:id/create' , async ( req , res ) => {
472
471
const valid = Validator . fromRequest ( req ) ;
473
- const passphrase = valid . str ( 'passphrase' ) ;
474
472
const sign = valid . bool ( 'sign' , true ) ;
475
473
474
+ // TODO: Add create TX with locks for used Coins and/or
475
+ // adds to the pending list.
476
476
const options = TransactionOptions . fromValidator ( valid ) ;
477
477
const tx = await req . wallet . createTX ( options ) ;
478
478
479
479
if ( sign )
480
- await req . wallet . sign ( tx , passphrase ) ;
480
+ await req . wallet . sign ( tx , options . passphrase ) ;
481
481
482
482
const json = tx . getJSON ( this . network ) ;
483
483
@@ -1068,23 +1068,26 @@ class HTTP extends Server {
1068
1068
this . post ( '/wallet/:id/open' , async ( req , res ) => {
1069
1069
const valid = Validator . fromRequest ( req ) ;
1070
1070
const name = valid . str ( 'name' ) ;
1071
- const passphrase = valid . str ( 'passphrase' ) ;
1072
1071
const broadcast = valid . bool ( 'broadcast' , true ) ;
1073
1072
const sign = valid . bool ( 'sign' , true ) ;
1074
1073
1075
1074
enforce ( name , 'Name is required.' ) ;
1076
1075
enforce ( broadcast ? sign : true , 'Must sign when broadcasting.' ) ;
1077
1076
1078
1077
const options = TransactionOptions . fromValidator ( valid ) ;
1079
- const mtx = await req . wallet . createOpen ( name , options ) ;
1080
1078
1081
1079
if ( broadcast ) {
1082
- const tx = await req . wallet . sendMTX ( mtx , passphrase ) ;
1080
+ // TODO: Add abort signal to close when request closes.
1081
+ const tx = await req . wallet . sendOpen ( name , options ) ;
1083
1082
return res . json ( 200 , tx . getJSON ( this . network ) ) ;
1084
1083
}
1085
1084
1085
+ // TODO: Add create TX with locks for used Coins and/or
1086
+ // adds to the pending list.
1087
+ const mtx = await req . wallet . createOpen ( name , options ) ;
1088
+
1086
1089
if ( sign )
1087
- await req . wallet . sign ( mtx , passphrase ) ;
1090
+ await req . wallet . sign ( mtx , options . passphrase ) ;
1088
1091
1089
1092
const json = mtx . getJSON ( this . network ) ;
1090
1093
@@ -1100,7 +1103,6 @@ class HTTP extends Server {
1100
1103
const name = valid . str ( 'name' ) ;
1101
1104
const bid = valid . u64 ( 'bid' ) ;
1102
1105
const lockup = valid . u64 ( 'lockup' ) ;
1103
- const passphrase = valid . str ( 'passphrase' ) ;
1104
1106
const broadcast = valid . bool ( 'broadcast' , true ) ;
1105
1107
const sign = valid . bool ( 'sign' , true ) ;
1106
1108
@@ -1110,15 +1112,19 @@ class HTTP extends Server {
1110
1112
enforce ( broadcast ? sign : true , 'Must sign when broadcasting.' ) ;
1111
1113
1112
1114
const options = TransactionOptions . fromValidator ( valid ) ;
1113
- const mtx = await req . wallet . createBid ( name , bid , lockup , options ) ;
1114
1115
1115
1116
if ( broadcast ) {
1116
- const tx = await req . wallet . sendMTX ( mtx , passphrase ) ;
1117
+ // TODO: Add abort signal to close when request closes.
1118
+ const tx = await req . wallet . sendBid ( name , bid , lockup , options ) ;
1117
1119
return res . json ( 200 , tx . getJSON ( this . network ) ) ;
1118
1120
}
1119
1121
1122
+ // TODO: Add create TX with locks for used Coins and/or
1123
+ // adds to the pending list.
1124
+ const mtx = await req . wallet . createBid ( name , bid , lockup , options ) ;
1125
+
1120
1126
if ( sign )
1121
- await req . wallet . sign ( mtx , passphrase ) ;
1127
+ await req . wallet . sign ( mtx , options . passphrase ) ;
1122
1128
1123
1129
const json = mtx . getJSON ( this . network ) ;
1124
1130
@@ -1180,29 +1186,39 @@ class HTTP extends Server {
1180
1186
this . post ( '/wallet/:id/reveal' , async ( req , res ) => {
1181
1187
const valid = Validator . fromRequest ( req ) ;
1182
1188
const name = valid . str ( 'name' ) ;
1183
- const passphrase = valid . str ( 'passphrase' ) ;
1184
1189
const broadcast = valid . bool ( 'broadcast' , true ) ;
1185
1190
const sign = valid . bool ( 'sign' , true ) ;
1186
1191
1187
1192
enforce ( broadcast ? sign : true , 'Must sign when broadcasting.' ) ;
1188
1193
1189
1194
const options = TransactionOptions . fromValidator ( valid ) ;
1190
1195
1191
- let mtx ;
1196
+ if ( broadcast ) {
1197
+ let tx ;
1192
1198
1193
- if ( ! name ) {
1194
- mtx = await req . wallet . createRevealAll ( options ) ;
1195
- } else {
1196
- mtx = await req . wallet . createReveal ( name , options ) ;
1197
- }
1199
+ if ( name ) {
1200
+ // TODO: Add abort signal to close when request closes.
1201
+ tx = await req . wallet . sendReveal ( name , options ) ;
1202
+ } else {
1203
+ // TODO: Add abort signal to close when request closes.
1204
+ tx = await req . wallet . sendRevealAll ( options ) ;
1205
+ }
1198
1206
1199
- if ( broadcast ) {
1200
- const tx = await req . wallet . sendMTX ( mtx , passphrase ) ;
1201
1207
return res . json ( 200 , tx . getJSON ( this . network ) ) ;
1202
1208
}
1203
1209
1210
+ let mtx ;
1211
+
1212
+ // TODO: Add create TX with locks for used Coins and/or
1213
+ // adds to the pending list.
1214
+ if ( name ) {
1215
+ mtx = await req . wallet . createReveal ( name , options ) ;
1216
+ } else {
1217
+ mtx = await req . wallet . createRevealAll ( options ) ;
1218
+ }
1219
+
1204
1220
if ( sign )
1205
- await req . wallet . sign ( mtx , passphrase ) ;
1221
+ await req . wallet . sign ( mtx , options . passphrase ) ;
1206
1222
1207
1223
const json = mtx . getJSON ( this . network ) ;
1208
1224
@@ -1216,29 +1232,39 @@ class HTTP extends Server {
1216
1232
this . post ( '/wallet/:id/redeem' , async ( req , res ) => {
1217
1233
const valid = Validator . fromRequest ( req ) ;
1218
1234
const name = valid . str ( 'name' ) ;
1219
- const passphrase = valid . str ( 'passphrase' ) ;
1220
1235
const broadcast = valid . bool ( 'broadcast' , true ) ;
1221
1236
const sign = valid . bool ( 'sign' , true ) ;
1222
1237
1223
1238
enforce ( broadcast ? sign : true , 'Must sign when broadcasting.' ) ;
1224
1239
1225
1240
const options = TransactionOptions . fromValidator ( valid ) ;
1226
1241
1242
+ if ( broadcast ) {
1243
+ let tx ;
1244
+
1245
+ if ( name ) {
1246
+ // TODO: Add abort signal to close when request closes.
1247
+ tx = await req . wallet . sendRedeem ( name , options ) ;
1248
+ } else {
1249
+ // TODO: Add abort signal to close when request closes.
1250
+ tx = await req . wallet . sendRedeemAll ( options ) ;
1251
+ }
1252
+
1253
+ return res . json ( 200 , tx . getJSON ( this . network ) ) ;
1254
+ }
1255
+
1227
1256
let mtx ;
1228
1257
1258
+ // TODO: Add create TX with locks for used Coins and/or
1259
+ // adds to the pending list.
1229
1260
if ( ! name ) {
1230
1261
mtx = await req . wallet . createRedeemAll ( options ) ;
1231
1262
} else {
1232
1263
mtx = await req . wallet . createRedeem ( name , options ) ;
1233
1264
}
1234
1265
1235
- if ( broadcast ) {
1236
- const tx = await req . wallet . sendMTX ( mtx , passphrase ) ;
1237
- return res . json ( 200 , tx . getJSON ( this . network ) ) ;
1238
- }
1239
-
1240
1266
if ( sign )
1241
- await req . wallet . sign ( mtx , passphrase ) ;
1267
+ await req . wallet . sign ( mtx , options . passphrase ) ;
1242
1268
1243
1269
const json = mtx . getJSON ( this . network ) ;
1244
1270
@@ -1253,7 +1279,6 @@ class HTTP extends Server {
1253
1279
const valid = Validator . fromRequest ( req ) ;
1254
1280
const name = valid . str ( 'name' ) ;
1255
1281
const data = valid . obj ( 'data' ) ;
1256
- const passphrase = valid . str ( 'passphrase' ) ;
1257
1282
const broadcast = valid . bool ( 'broadcast' , true ) ;
1258
1283
const sign = valid . bool ( 'sign' , true ) ;
1259
1284
@@ -1269,15 +1294,19 @@ class HTTP extends Server {
1269
1294
}
1270
1295
1271
1296
const options = TransactionOptions . fromValidator ( valid ) ;
1272
- const mtx = await req . wallet . createUpdate ( name , resource , options ) ;
1273
1297
1274
1298
if ( broadcast ) {
1275
- const tx = await req . wallet . sendMTX ( mtx , passphrase ) ;
1299
+ // TODO: Add abort signal to close when request closes.
1300
+ const tx = await req . wallet . sendUpdate ( name , resource , options ) ;
1276
1301
return res . json ( 200 , tx . getJSON ( this . network ) ) ;
1277
1302
}
1278
1303
1304
+ // TODO: Add create TX with locks for used Coins and/or
1305
+ // adds to the pending list.
1306
+ const mtx = await req . wallet . createUpdate ( name , resource , options ) ;
1307
+
1279
1308
if ( sign )
1280
- await req . wallet . sign ( mtx , passphrase ) ;
1309
+ await req . wallet . sign ( mtx , options . passphrase ) ;
1281
1310
1282
1311
const json = mtx . getJSON ( this . network ) ;
1283
1312
@@ -1291,23 +1320,24 @@ class HTTP extends Server {
1291
1320
this . post ( '/wallet/:id/renewal' , async ( req , res ) => {
1292
1321
const valid = Validator . fromRequest ( req ) ;
1293
1322
const name = valid . str ( 'name' ) ;
1294
- const passphrase = valid . str ( 'passphrase' ) ;
1295
1323
const broadcast = valid . bool ( 'broadcast' , true ) ;
1296
1324
const sign = valid . bool ( 'sign' , true ) ;
1297
1325
1298
1326
enforce ( broadcast ? sign : true , 'Must sign when broadcasting.' ) ;
1299
1327
enforce ( name , 'Must pass name.' ) ;
1300
1328
1301
1329
const options = TransactionOptions . fromValidator ( valid ) ;
1302
- const mtx = await req . wallet . createRenewal ( name , options ) ;
1303
1330
1304
1331
if ( broadcast ) {
1305
- const tx = await req . wallet . sendMTX ( mtx , passphrase ) ;
1332
+ // TODO: Add abort signal to close when request closes.
1333
+ const tx = await req . wallet . sendRenewal ( name , options ) ;
1306
1334
return res . json ( 200 , tx . getJSON ( this . network ) ) ;
1307
1335
}
1308
1336
1337
+ const mtx = await req . wallet . createRenewal ( name , options ) ;
1338
+
1309
1339
if ( sign )
1310
- await req . wallet . sign ( mtx , passphrase ) ;
1340
+ await req . wallet . sign ( mtx , options . passphrase ) ;
1311
1341
1312
1342
const json = mtx . getJSON ( this . network ) ;
1313
1343
@@ -1322,7 +1352,6 @@ class HTTP extends Server {
1322
1352
const valid = Validator . fromRequest ( req ) ;
1323
1353
const name = valid . str ( 'name' ) ;
1324
1354
const address = valid . str ( 'address' ) ;
1325
- const passphrase = valid . str ( 'passphrase' ) ;
1326
1355
const broadcast = valid . bool ( 'broadcast' , true ) ;
1327
1356
const sign = valid . bool ( 'sign' , true ) ;
1328
1357
@@ -1332,15 +1361,19 @@ class HTTP extends Server {
1332
1361
1333
1362
const addr = Address . fromString ( address , this . network ) ;
1334
1363
const options = TransactionOptions . fromValidator ( valid ) ;
1335
- const mtx = await req . wallet . createTransfer ( name , addr , options ) ;
1336
1364
1337
1365
if ( broadcast ) {
1338
- const tx = await req . wallet . sendMTX ( mtx , passphrase ) ;
1366
+ // TODO: Add abort signal to close when request closes.
1367
+ const tx = await req . wallet . sendTransfer ( name , addr , options ) ;
1339
1368
return res . json ( 200 , tx . getJSON ( this . network ) ) ;
1340
1369
}
1341
1370
1371
+ // TODO: Add create TX with locks for used Coins and/or
1372
+ // adds to the pending list.
1373
+ const mtx = await req . wallet . createTransfer ( name , addr , options ) ;
1374
+
1342
1375
if ( sign )
1343
- await req . wallet . sign ( mtx , passphrase ) ;
1376
+ await req . wallet . sign ( mtx , options . passphrase ) ;
1344
1377
1345
1378
const json = mtx . getJSON ( this . network ) ;
1346
1379
@@ -1354,23 +1387,26 @@ class HTTP extends Server {
1354
1387
this . post ( '/wallet/:id/cancel' , async ( req , res ) => {
1355
1388
const valid = Validator . fromRequest ( req ) ;
1356
1389
const name = valid . str ( 'name' ) ;
1357
- const passphrase = valid . str ( 'passphrase' ) ;
1358
1390
const broadcast = valid . bool ( 'broadcast' , true ) ;
1359
1391
const sign = valid . bool ( 'sign' , true ) ;
1360
1392
1361
1393
enforce ( broadcast ? sign : true , 'Must sign when broadcasting.' ) ;
1362
1394
enforce ( name , 'Must pass name.' ) ;
1363
1395
1364
1396
const options = TransactionOptions . fromValidator ( valid ) ;
1365
- const mtx = await req . wallet . createCancel ( name , options ) ;
1366
1397
1367
1398
if ( broadcast ) {
1368
- const tx = await req . wallet . sendMTX ( mtx , passphrase ) ;
1399
+ // TODO: Add abort signal to close when request closes.
1400
+ const tx = await req . wallet . sendCancel ( name , options ) ;
1369
1401
return res . json ( 200 , tx . getJSON ( this . network ) ) ;
1370
1402
}
1371
1403
1404
+ // TODO: Add create TX with locks for used Coins and/or
1405
+ // adds to the pending list.
1406
+ const mtx = await req . wallet . createCancel ( name , options ) ;
1407
+
1372
1408
if ( sign )
1373
- await req . wallet . sign ( mtx , passphrase ) ;
1409
+ await req . wallet . sign ( mtx , options . passphrase ) ;
1374
1410
1375
1411
const json = mtx . getJSON ( this . network ) ;
1376
1412
@@ -1384,23 +1420,24 @@ class HTTP extends Server {
1384
1420
this . post ( '/wallet/:id/finalize' , async ( req , res ) => {
1385
1421
const valid = Validator . fromRequest ( req ) ;
1386
1422
const name = valid . str ( 'name' ) ;
1387
- const passphrase = valid . str ( 'passphrase' ) ;
1388
1423
const broadcast = valid . bool ( 'broadcast' , true ) ;
1389
1424
const sign = valid . bool ( 'sign' , true ) ;
1390
1425
1391
1426
enforce ( broadcast ? sign : true , 'Must sign when broadcasting.' ) ;
1392
1427
enforce ( name , 'Must pass name.' ) ;
1393
1428
1394
1429
const options = TransactionOptions . fromValidator ( valid ) ;
1395
- const mtx = await req . wallet . createFinalize ( name , options ) ;
1396
1430
1397
1431
if ( broadcast ) {
1398
- const tx = await req . wallet . sendMTX ( mtx , passphrase ) ;
1432
+ // TODO: Add abort signal to close when request closes.
1433
+ const tx = await req . wallet . sendFinalize ( name , options ) ;
1399
1434
return res . json ( 200 , tx . getJSON ( this . network ) ) ;
1400
1435
}
1401
1436
1437
+ const mtx = await req . wallet . createFinalize ( name , options ) ;
1438
+
1402
1439
if ( sign )
1403
- await req . wallet . sign ( mtx , passphrase ) ;
1440
+ await req . wallet . sign ( mtx , options . passphrase ) ;
1404
1441
1405
1442
const json = mtx . getJSON ( this . network ) ;
1406
1443
@@ -1414,23 +1451,26 @@ class HTTP extends Server {
1414
1451
this . post ( '/wallet/:id/revoke' , async ( req , res ) => {
1415
1452
const valid = Validator . fromRequest ( req ) ;
1416
1453
const name = valid . str ( 'name' ) ;
1417
- const passphrase = valid . str ( 'passphrase' ) ;
1418
1454
const broadcast = valid . bool ( 'broadcast' , true ) ;
1419
1455
const sign = valid . bool ( 'sign' , true ) ;
1420
1456
1421
1457
enforce ( broadcast ? sign : true , 'Must sign when broadcasting.' ) ;
1422
1458
enforce ( name , 'Must pass name.' ) ;
1423
1459
1424
1460
const options = TransactionOptions . fromValidator ( valid ) ;
1425
- const mtx = await req . wallet . createRevoke ( name , options ) ;
1426
1461
1427
1462
if ( broadcast ) {
1428
- const tx = await req . wallet . sendMTX ( mtx , passphrase ) ;
1463
+ // TODO: Add abort signal to close when request closes.
1464
+ const tx = await req . wallet . sendRevoke ( name , options ) ;
1429
1465
return res . json ( 200 , tx . getJSON ( this . network ) ) ;
1430
1466
}
1431
1467
1468
+ // TODO: Add create TX with locks for used Coins and/or
1469
+ // adds to the pending list.
1470
+ const mtx = await req . wallet . createRevoke ( name , options ) ;
1471
+
1432
1472
if ( sign )
1433
- await req . wallet . sign ( mtx , passphrase ) ;
1473
+ await req . wallet . sign ( mtx , options . passphrase ) ;
1434
1474
1435
1475
const json = mtx . getJSON ( this . network ) ;
1436
1476
@@ -1814,6 +1854,8 @@ class TransactionOptions {
1814
1854
this . subtractIndex = valid . i32 ( 'subtractIndex' ) ;
1815
1855
this . depth = valid . u32 ( [ 'confirmations' , 'depth' ] ) ;
1816
1856
this . paths = valid . bool ( 'paths' ) ;
1857
+ this . passphrase = valid . str ( 'passphrase' ) ;
1858
+ this . hardFee = valid . u64 ( 'hardFee' ) ,
1817
1859
this . outputs = [ ] ;
1818
1860
1819
1861
if ( valid . has ( 'outputs' ) ) {
0 commit comments