@runflame/wallet-rn 0.0.1-rc.0 → 0.0.1-rc.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -604,8 +604,11 @@ fileprivate struct FfiConverterData: FfiConverterRustBuffer {
604
604
  /**
605
605
  * One account, `m/35263'/network'/0'`, behind an opaque handle.
606
606
  *
607
- * The handle is the only thing that ever holds key material: every
608
- * spending key is derived inside a call and dropped before it returns. It
607
+ * The handle holds the account key, and every child key is derived inside
608
+ * a call and dropped before it returns. Two calls hand key material out,
609
+ * and the caller must keep what they return as secret as the wallet
610
+ * itself: [`Wallet::view_key`] reads every amount and memo, and
611
+ * [`Wallet::receiving_key`] links every address. Neither can spend. It
609
612
  * is safe to share across threads. Calls that read or advance the counter
610
613
  * are serialized; [`Wallet::build_transfer`] works on a copy and holds no
611
614
  * lock while it proves.
@@ -625,9 +628,17 @@ public protocol WalletProtocol: AnyObject, Sendable {
625
628
  * account with the lock released: other calls on this handle, from a
626
629
  * UI thread say, do not wait for it. The build never touches the
627
630
  * counter, so nothing the copy does needs writing back.
631
+ *
632
+ * Only a spend wallet builds; the others refuse with
633
+ * [`FlameError::NotPermitted`] before reading the request.
628
634
  */
629
635
  func buildTransfer(request: TransferRequest) throws -> Transfer
630
636
 
637
+ /**
638
+ * What this wallet was built from, and so what it can do.
639
+ */
640
+ func kind() -> WalletKind
641
+
631
642
  /**
632
643
  * The network this wallet's addresses are encoded for.
633
644
  */
@@ -643,6 +654,15 @@ public protocol WalletProtocol: AnyObject, Sendable {
643
654
  */
644
655
  func nextIndex() -> UInt32
645
656
 
657
+ /**
658
+ * Opens the note that followed `contract` in its log, as a scan serves
659
+ * the pair; `note` is `None` when the scan served none. `path` is what
660
+ * [`Wallet::owns`] found for the contract's predicate. The opening it
661
+ * gives is what a later [`crate::TransferInput`] spends the output with.
662
+ * A receive wallet cannot open notes.
663
+ */
664
+ func openNote(contract: Data, note: Data?, path: KeyPath) throws -> ReceivedNote
665
+
646
666
  /**
647
667
  * Which path below `next_index + gap`, on either branch, owns
648
668
  * `predicate`; `None` if none does. The scan re-derives every address
@@ -658,12 +678,23 @@ public protocol WalletProtocol: AnyObject, Sendable {
658
678
  */
659
679
  func receivingKey() -> String
660
680
 
681
+ /**
682
+ * The account's view key in bech32f (`view1…` / `testview1…`): what a
683
+ * view wallet is built from. It derives every address and opens every
684
+ * note, so it reads every amount and memo, but it cannot spend. Store
685
+ * it as a secret. A receive wallet has none to give.
686
+ */
687
+ func viewKey() throws -> String
688
+
661
689
  }
662
690
  /**
663
691
  * One account, `m/35263'/network'/0'`, behind an opaque handle.
664
692
  *
665
- * The handle is the only thing that ever holds key material: every
666
- * spending key is derived inside a call and dropped before it returns. It
693
+ * The handle holds the account key, and every child key is derived inside
694
+ * a call and dropped before it returns. Two calls hand key material out,
695
+ * and the caller must keep what they return as secret as the wallet
696
+ * itself: [`Wallet::view_key`] reads every amount and memo, and
697
+ * [`Wallet::receiving_key`] links every address. Neither can spend. It
667
698
  * is safe to share across threads. Calls that read or advance the counter
668
699
  * are serialized; [`Wallet::build_transfer`] works on a copy and holds no
669
700
  * lock while it proves.
@@ -753,6 +784,50 @@ public static func fromMnemonic(phrase: String, passphrase: String, network: Net
753
784
  })
754
785
  }
755
786
 
787
+ /**
788
+ * A receive wallet from the account's receiving key in bech32f, as
789
+ * [`Wallet::receiving_key`] gives it, for `network`; `next_index` as
790
+ * in [`Wallet::new`]. It issues addresses and finds payments;
791
+ * [`Wallet::view_key`], [`Wallet::open_note`] and
792
+ * [`Wallet::build_transfer`] refuse with [`FlameError::NotPermitted`].
793
+ *
794
+ * As with [`Wallet::from_view_key`], it must be the account node's
795
+ * key: one from any other node is accepted and silently owns nothing.
796
+ */
797
+ public static func fromReceivingKey(receivingKey: String, network: Network, nextIndex: UInt32)throws -> Wallet {
798
+ return try FfiConverterTypeWallet_lift(try rustCallWithError(FfiConverterTypeFlameError_lift) {
799
+ uniffiCallStatus in
800
+ uniffi_flamewallet_ffi_fn_constructor_wallet_from_receiving_key(
801
+ FfiConverterString.lower(receivingKey),
802
+ FfiConverterTypeNetwork_lower(network),
803
+ FfiConverterUInt32.lower(nextIndex),uniffiCallStatus
804
+ )
805
+ })
806
+ }
807
+
808
+ /**
809
+ * A view wallet from the account's view key in bech32f, as
810
+ * [`Wallet::view_key`] gives it, for `network`; `next_index` as in
811
+ * [`Wallet::new`]. Every call works except
812
+ * [`Wallet::build_transfer`], which refuses with
813
+ * [`FlameError::NotPermitted`].
814
+ *
815
+ * It must be the key of the account node, `m/35263'/network'/0'`,
816
+ * exactly as [`Wallet::view_key`] exports it. The encoding carries no
817
+ * depth, so a key from any other node is accepted too, and that
818
+ * wallet silently owns nothing: every `owns` is `None`.
819
+ */
820
+ public static func fromViewKey(viewKey: String, network: Network, nextIndex: UInt32)throws -> Wallet {
821
+ return try FfiConverterTypeWallet_lift(try rustCallWithError(FfiConverterTypeFlameError_lift) {
822
+ uniffiCallStatus in
823
+ uniffi_flamewallet_ffi_fn_constructor_wallet_from_view_key(
824
+ FfiConverterString.lower(viewKey),
825
+ FfiConverterTypeNetwork_lower(network),
826
+ FfiConverterUInt32.lower(nextIndex),uniffiCallStatus
827
+ )
828
+ })
829
+ }
830
+
756
831
 
757
832
 
758
833
  /**
@@ -776,6 +851,9 @@ open func address(path: KeyPath)throws -> IssuedAddress {
776
851
  * account with the lock released: other calls on this handle, from a
777
852
  * UI thread say, do not wait for it. The build never touches the
778
853
  * counter, so nothing the copy does needs writing back.
854
+ *
855
+ * Only a spend wallet builds; the others refuse with
856
+ * [`FlameError::NotPermitted`] before reading the request.
779
857
  */
780
858
  open func buildTransfer(request: TransferRequest)throws -> Transfer {
781
859
  return try FfiConverterTypeTransfer_lift(try rustCallWithError(FfiConverterTypeFlameError_lift) {
@@ -785,6 +863,18 @@ open func buildTransfer(request: TransferRequest)throws -> Transfer {
785
863
  FfiConverterTypeTransferRequest_lower(request),uniffiCallStatus
786
864
  )
787
865
  })
866
+ }
867
+
868
+ /**
869
+ * What this wallet was built from, and so what it can do.
870
+ */
871
+ open func kind() -> WalletKind {
872
+ return try! FfiConverterTypeWalletKind_lift(try! rustCall() {
873
+ uniffiCallStatus in
874
+ uniffi_flamewallet_ffi_fn_method_wallet_kind(
875
+ self.uniffiCloneHandle(),uniffiCallStatus
876
+ )
877
+ })
788
878
  }
789
879
 
790
880
  /**
@@ -821,6 +911,25 @@ open func nextIndex() -> UInt32 {
821
911
  self.uniffiCloneHandle(),uniffiCallStatus
822
912
  )
823
913
  })
914
+ }
915
+
916
+ /**
917
+ * Opens the note that followed `contract` in its log, as a scan serves
918
+ * the pair; `note` is `None` when the scan served none. `path` is what
919
+ * [`Wallet::owns`] found for the contract's predicate. The opening it
920
+ * gives is what a later [`crate::TransferInput`] spends the output with.
921
+ * A receive wallet cannot open notes.
922
+ */
923
+ open func openNote(contract: Data, note: Data?, path: KeyPath)throws -> ReceivedNote {
924
+ return try FfiConverterTypeReceivedNote_lift(try rustCallWithError(FfiConverterTypeFlameError_lift) {
925
+ uniffiCallStatus in
926
+ uniffi_flamewallet_ffi_fn_method_wallet_open_note(
927
+ self.uniffiCloneHandle(),
928
+ FfiConverterData.lower(contract),
929
+ FfiConverterOptionData.lower(note),
930
+ FfiConverterTypeKeyPath_lower(path),uniffiCallStatus
931
+ )
932
+ })
824
933
  }
825
934
 
826
935
  /**
@@ -854,6 +963,21 @@ open func receivingKey() -> String {
854
963
  })
855
964
  }
856
965
 
966
+ /**
967
+ * The account's view key in bech32f (`view1…` / `testview1…`): what a
968
+ * view wallet is built from. It derives every address and opens every
969
+ * note, so it reads every amount and memo, but it cannot spend. Store
970
+ * it as a secret. A receive wallet has none to give.
971
+ */
972
+ open func viewKey()throws -> String {
973
+ return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeFlameError_lift) {
974
+ uniffiCallStatus in
975
+ uniffi_flamewallet_ffi_fn_method_wallet_view_key(
976
+ self.uniffiCloneHandle(),uniffiCallStatus
977
+ )
978
+ })
979
+ }
980
+
857
981
 
858
982
 
859
983
  }
@@ -978,7 +1102,7 @@ public func FfiConverterTypeContractInfo_lower(_ value: ContractInfo) -> RustBuf
978
1102
 
979
1103
 
980
1104
  /**
981
- * One contract the transfer creates, in request order.
1105
+ * One contract the transfer creates.
982
1106
  */
983
1107
  public struct CreatedOutput: Equatable, Hashable {
984
1108
  public var contractId: Data
@@ -987,10 +1111,11 @@ public struct CreatedOutput: Equatable, Hashable {
987
1111
  */
988
1112
  public var contract: Data
989
1113
  /**
990
- * Delivered to the recipient out of band, or kept for change: the
991
- * output can be spent from this record and nothing else.
1114
+ * The encrypted note that follows it on chain, as an indexer's scan
1115
+ * serves it. Its recipient opens it with [`crate::Wallet::open_note`];
1116
+ * so does this wallet, for its change.
992
1117
  */
993
- public var opening: Opening
1118
+ public var note: Data
994
1119
 
995
1120
  // Default memberwise initializers are never public by default, so we
996
1121
  // declare one manually.
@@ -999,12 +1124,13 @@ public struct CreatedOutput: Equatable, Hashable {
999
1124
  * Its published bytes, as an indexer will serve them once confirmed.
1000
1125
  */contract: Data,
1001
1126
  /**
1002
- * Delivered to the recipient out of band, or kept for change: the
1003
- * output can be spent from this record and nothing else.
1004
- */opening: Opening) {
1127
+ * The encrypted note that follows it on chain, as an indexer's scan
1128
+ * serves it. Its recipient opens it with [`crate::Wallet::open_note`];
1129
+ * so does this wallet, for its change.
1130
+ */note: Data) {
1005
1131
  self.contractId = contractId
1006
1132
  self.contract = contract
1007
- self.opening = opening
1133
+ self.note = note
1008
1134
  }
1009
1135
 
1010
1136
 
@@ -1025,14 +1151,14 @@ public struct FfiConverterTypeCreatedOutput: FfiConverterRustBuffer {
1025
1151
  try CreatedOutput(
1026
1152
  contractId: FfiConverterData.read(from: &buf),
1027
1153
  contract: FfiConverterData.read(from: &buf),
1028
- opening: FfiConverterTypeOpening.read(from: &buf)
1154
+ note: FfiConverterData.read(from: &buf)
1029
1155
  )
1030
1156
  }
1031
1157
 
1032
1158
  public static func write(_ value: CreatedOutput, into buf: inout [UInt8]) {
1033
1159
  FfiConverterData.write(value.contractId, into: &buf)
1034
1160
  FfiConverterData.write(value.contract, into: &buf)
1035
- FfiConverterTypeOpening.write(value.opening, into: &buf)
1161
+ FfiConverterData.write(value.note, into: &buf)
1036
1162
  }
1037
1163
  }
1038
1164
 
@@ -1250,6 +1376,75 @@ public func FfiConverterTypeOpening_lower(_ value: Opening) -> RustBuffer {
1250
1376
  }
1251
1377
 
1252
1378
 
1379
+ /**
1380
+ * What an opened note gives its recipient.
1381
+ */
1382
+ public struct ReceivedNote: Equatable, Hashable {
1383
+ /**
1384
+ * What a [`crate::TransferInput`] spends the output with.
1385
+ */
1386
+ public var opening: Opening
1387
+ /**
1388
+ * The memo, as the sender wrote it.
1389
+ */
1390
+ public var memo: Data
1391
+
1392
+ // Default memberwise initializers are never public by default, so we
1393
+ // declare one manually.
1394
+ public init(
1395
+ /**
1396
+ * What a [`crate::TransferInput`] spends the output with.
1397
+ */opening: Opening,
1398
+ /**
1399
+ * The memo, as the sender wrote it.
1400
+ */memo: Data) {
1401
+ self.opening = opening
1402
+ self.memo = memo
1403
+ }
1404
+
1405
+
1406
+
1407
+
1408
+ }
1409
+
1410
+ #if compiler(>=6)
1411
+ extension ReceivedNote: Sendable {}
1412
+ #endif
1413
+
1414
+ #if swift(>=5.8)
1415
+ @_documentation(visibility: private)
1416
+ #endif
1417
+ public struct FfiConverterTypeReceivedNote: FfiConverterRustBuffer {
1418
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ReceivedNote {
1419
+ return
1420
+ try ReceivedNote(
1421
+ opening: FfiConverterTypeOpening.read(from: &buf),
1422
+ memo: FfiConverterData.read(from: &buf)
1423
+ )
1424
+ }
1425
+
1426
+ public static func write(_ value: ReceivedNote, into buf: inout [UInt8]) {
1427
+ FfiConverterTypeOpening.write(value.opening, into: &buf)
1428
+ FfiConverterData.write(value.memo, into: &buf)
1429
+ }
1430
+ }
1431
+
1432
+
1433
+ #if swift(>=5.8)
1434
+ @_documentation(visibility: private)
1435
+ #endif
1436
+ public func FfiConverterTypeReceivedNote_lift(_ buf: RustBuffer) throws -> ReceivedNote {
1437
+ return try FfiConverterTypeReceivedNote.lift(buf)
1438
+ }
1439
+
1440
+ #if swift(>=5.8)
1441
+ @_documentation(visibility: private)
1442
+ #endif
1443
+ public func FfiConverterTypeReceivedNote_lower(_ value: ReceivedNote) -> RustBuffer {
1444
+ return FfiConverterTypeReceivedNote.lower(value)
1445
+ }
1446
+
1447
+
1253
1448
  /**
1254
1449
  * A signed transfer, ready to publish.
1255
1450
  */
@@ -1262,6 +1457,11 @@ public struct Transfer: Equatable, Hashable {
1262
1457
  * `BlockTx::to_bytes`: what a node's `submit_tx` takes.
1263
1458
  */
1264
1459
  public var blockTx: Data
1460
+ /**
1461
+ * In the order they are published, which is not request order: the
1462
+ * builder sorts them so that position says nothing about which one is
1463
+ * the change. Match one to its request by its predicate.
1464
+ */
1265
1465
  public var outputs: [CreatedOutput]
1266
1466
 
1267
1467
  // Default memberwise initializers are never public by default, so we
@@ -1272,7 +1472,12 @@ public struct Transfer: Equatable, Hashable {
1272
1472
  */txid: Data,
1273
1473
  /**
1274
1474
  * `BlockTx::to_bytes`: what a node's `submit_tx` takes.
1275
- */blockTx: Data, outputs: [CreatedOutput]) {
1475
+ */blockTx: Data,
1476
+ /**
1477
+ * In the order they are published, which is not request order: the
1478
+ * builder sorts them so that position says nothing about which one is
1479
+ * the change. Match one to its request by its predicate.
1480
+ */outputs: [CreatedOutput]) {
1276
1481
  self.txid = txid
1277
1482
  self.blockTx = blockTx
1278
1483
  self.outputs = outputs
@@ -1417,29 +1622,39 @@ public func FfiConverterTypeTransferInput_lower(_ value: TransferInput) -> RustB
1417
1622
  */
1418
1623
  public struct TransferOutput: Equatable, Hashable {
1419
1624
  /**
1420
- * The recipient's predicate: [`crate::address_to_predicate`], or
1421
- * [`crate::Wallet::address`] on the change branch.
1625
+ * The recipient's bech32f address, for the wallet's network; for
1626
+ * change, [`crate::Wallet::address`] on the change branch.
1422
1627
  */
1423
- public var predicate: Data
1628
+ public var address: String
1424
1629
  public var qty: UInt64
1425
1630
  /**
1426
1631
  * `None` for flames.
1427
1632
  */
1428
1633
  public var flavor: Data?
1634
+ /**
1635
+ * Sealed into the output's note with the amount; only the recipient
1636
+ * reads it. At most 4006 bytes; empty for none.
1637
+ */
1638
+ public var memo: Data
1429
1639
 
1430
1640
  // Default memberwise initializers are never public by default, so we
1431
1641
  // declare one manually.
1432
1642
  public init(
1433
1643
  /**
1434
- * The recipient's predicate: [`crate::address_to_predicate`], or
1435
- * [`crate::Wallet::address`] on the change branch.
1436
- */predicate: Data, qty: UInt64,
1644
+ * The recipient's bech32f address, for the wallet's network; for
1645
+ * change, [`crate::Wallet::address`] on the change branch.
1646
+ */address: String, qty: UInt64,
1437
1647
  /**
1438
1648
  * `None` for flames.
1439
- */flavor: Data?) {
1440
- self.predicate = predicate
1649
+ */flavor: Data?,
1650
+ /**
1651
+ * Sealed into the output's note with the amount; only the recipient
1652
+ * reads it. At most 4006 bytes; empty for none.
1653
+ */memo: Data) {
1654
+ self.address = address
1441
1655
  self.qty = qty
1442
1656
  self.flavor = flavor
1657
+ self.memo = memo
1443
1658
  }
1444
1659
 
1445
1660
 
@@ -1458,16 +1673,18 @@ public struct FfiConverterTypeTransferOutput: FfiConverterRustBuffer {
1458
1673
  public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TransferOutput {
1459
1674
  return
1460
1675
  try TransferOutput(
1461
- predicate: FfiConverterData.read(from: &buf),
1676
+ address: FfiConverterString.read(from: &buf),
1462
1677
  qty: FfiConverterUInt64.read(from: &buf),
1463
- flavor: FfiConverterOptionData.read(from: &buf)
1678
+ flavor: FfiConverterOptionData.read(from: &buf),
1679
+ memo: FfiConverterData.read(from: &buf)
1464
1680
  )
1465
1681
  }
1466
1682
 
1467
1683
  public static func write(_ value: TransferOutput, into buf: inout [UInt8]) {
1468
- FfiConverterData.write(value.predicate, into: &buf)
1684
+ FfiConverterString.write(value.address, into: &buf)
1469
1685
  FfiConverterUInt64.write(value.qty, into: &buf)
1470
1686
  FfiConverterOptionData.write(value.flavor, into: &buf)
1687
+ FfiConverterData.write(value.memo, into: &buf)
1471
1688
  }
1472
1689
  }
1473
1690
 
@@ -1680,6 +1897,19 @@ enum FlameError: Swift.Error, Equatable, Hashable, Foundation.LocalizedError {
1680
1897
  */
1681
1898
  case InvalidSeed(reason: String
1682
1899
  )
1900
+ /**
1901
+ * A view or receiving key does not parse for the wallet's network, or
1902
+ * flamekd refused to derive from the key a wallet holds.
1903
+ */
1904
+ case InvalidKey(reason: String
1905
+ )
1906
+ /**
1907
+ * The wallet's key does not allow the call: a view wallet cannot
1908
+ * spend, and a receive wallet can neither spend nor open notes.
1909
+ * `wallet` is this wallet's kind, `needs` the least kind that could.
1910
+ */
1911
+ case NotPermitted(wallet: WalletKind, needs: WalletKind
1912
+ )
1683
1913
  /**
1684
1914
  * An address does not parse for the wallet's network.
1685
1915
  */
@@ -1702,6 +1932,12 @@ enum FlameError: Swift.Error, Equatable, Hashable, Foundation.LocalizedError {
1702
1932
  */
1703
1933
  case KeyMismatch(input: UInt32
1704
1934
  )
1935
+ /**
1936
+ * A note did not open; `failure` says how, and so what the wallet does
1937
+ * with the output.
1938
+ */
1939
+ case Note(failure: NoteFailure, reason: String
1940
+ )
1705
1941
  /**
1706
1942
  * The transfer could not be built or signed.
1707
1943
  */
@@ -1742,20 +1978,31 @@ public struct FfiConverterTypeFlameError: FfiConverterRustBuffer {
1742
1978
  case 2: return .InvalidSeed(
1743
1979
  reason: try FfiConverterString.read(from: &buf)
1744
1980
  )
1745
- case 3: return .InvalidAddress(
1981
+ case 3: return .InvalidKey(
1982
+ reason: try FfiConverterString.read(from: &buf)
1983
+ )
1984
+ case 4: return .NotPermitted(
1985
+ wallet: try FfiConverterTypeWalletKind.read(from: &buf),
1986
+ needs: try FfiConverterTypeWalletKind.read(from: &buf)
1987
+ )
1988
+ case 5: return .InvalidAddress(
1746
1989
  reason: try FfiConverterString.read(from: &buf)
1747
1990
  )
1748
- case 4: return .InvalidKeyPath(
1991
+ case 6: return .InvalidKeyPath(
1749
1992
  reason: try FfiConverterString.read(from: &buf)
1750
1993
  )
1751
- case 5: return .InvalidBytes(
1994
+ case 7: return .InvalidBytes(
1752
1995
  what: try FfiConverterString.read(from: &buf),
1753
1996
  reason: try FfiConverterString.read(from: &buf)
1754
1997
  )
1755
- case 6: return .KeyMismatch(
1998
+ case 8: return .KeyMismatch(
1756
1999
  input: try FfiConverterUInt32.read(from: &buf)
1757
2000
  )
1758
- case 7: return .Transfer(
2001
+ case 9: return .Note(
2002
+ failure: try FfiConverterTypeNoteFailure.read(from: &buf),
2003
+ reason: try FfiConverterString.read(from: &buf)
2004
+ )
2005
+ case 10: return .Transfer(
1759
2006
  reason: try FfiConverterString.read(from: &buf)
1760
2007
  )
1761
2008
 
@@ -1780,29 +2027,46 @@ public struct FfiConverterTypeFlameError: FfiConverterRustBuffer {
1780
2027
  FfiConverterString.write(reason, into: &buf)
1781
2028
 
1782
2029
 
1783
- case let .InvalidAddress(reason):
2030
+ case let .InvalidKey(reason):
1784
2031
  writeInt(&buf, Int32(3))
1785
2032
  FfiConverterString.write(reason, into: &buf)
1786
2033
 
1787
2034
 
1788
- case let .InvalidKeyPath(reason):
2035
+ case let .NotPermitted(wallet,needs):
1789
2036
  writeInt(&buf, Int32(4))
2037
+ FfiConverterTypeWalletKind.write(wallet, into: &buf)
2038
+ FfiConverterTypeWalletKind.write(needs, into: &buf)
2039
+
2040
+
2041
+ case let .InvalidAddress(reason):
2042
+ writeInt(&buf, Int32(5))
2043
+ FfiConverterString.write(reason, into: &buf)
2044
+
2045
+
2046
+ case let .InvalidKeyPath(reason):
2047
+ writeInt(&buf, Int32(6))
1790
2048
  FfiConverterString.write(reason, into: &buf)
1791
2049
 
1792
2050
 
1793
2051
  case let .InvalidBytes(what,reason):
1794
- writeInt(&buf, Int32(5))
2052
+ writeInt(&buf, Int32(7))
1795
2053
  FfiConverterString.write(what, into: &buf)
1796
2054
  FfiConverterString.write(reason, into: &buf)
1797
2055
 
1798
2056
 
1799
2057
  case let .KeyMismatch(input):
1800
- writeInt(&buf, Int32(6))
2058
+ writeInt(&buf, Int32(8))
1801
2059
  FfiConverterUInt32.write(input, into: &buf)
1802
2060
 
1803
2061
 
2062
+ case let .Note(failure,reason):
2063
+ writeInt(&buf, Int32(9))
2064
+ FfiConverterTypeNoteFailure.write(failure, into: &buf)
2065
+ FfiConverterString.write(reason, into: &buf)
2066
+
2067
+
1804
2068
  case let .Transfer(reason):
1805
- writeInt(&buf, Int32(7))
2069
+ writeInt(&buf, Int32(10))
1806
2070
  FfiConverterString.write(reason, into: &buf)
1807
2071
 
1808
2072
  }
@@ -1893,6 +2157,212 @@ public func FfiConverterTypeNetwork_lower(_ value: Network) -> RustBuffer {
1893
2157
  }
1894
2158
 
1895
2159
 
2160
+
2161
+ /**
2162
+ * Why a note did not open: the outcomes of `docs/payments.md`
2163
+ * "Receiving", which a wallet treats differently.
2164
+ */
2165
+
2166
+ public enum NoteFailure: Equatable, Hashable {
2167
+
2168
+ /**
2169
+ * No note followed the output. The output is ours but unreadable: keep
2170
+ * and list it, and leave it out of the balance.
2171
+ */
2172
+ case missing
2173
+ /**
2174
+ * The note is malformed. Treated as [`NoteFailure::Missing`].
2175
+ */
2176
+ case malformed
2177
+ /**
2178
+ * A note version this library does not know; a later one may open it.
2179
+ */
2180
+ case unknownVersion
2181
+ /**
2182
+ * The note does not decrypt under this address. Treated as
2183
+ * [`NoteFailure::Missing`].
2184
+ */
2185
+ case undecryptable
2186
+ /**
2187
+ * The note decrypts but misstates its output: the sender erred or lied.
2188
+ * Keep and flag it; never count it.
2189
+ */
2190
+ case openingMismatch
2191
+ /**
2192
+ * The contract is a cleartext token, or not a token: there is no note
2193
+ * to open, and [`crate::decode_contract`] reads its amount.
2194
+ */
2195
+ case notConfidential
2196
+
2197
+
2198
+
2199
+
2200
+
2201
+ }
2202
+
2203
+ #if compiler(>=6)
2204
+ extension NoteFailure: Sendable {}
2205
+ #endif
2206
+
2207
+ #if swift(>=5.8)
2208
+ @_documentation(visibility: private)
2209
+ #endif
2210
+ public struct FfiConverterTypeNoteFailure: FfiConverterRustBuffer {
2211
+ typealias SwiftType = NoteFailure
2212
+
2213
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> NoteFailure {
2214
+ let variant: Int32 = try readInt(&buf)
2215
+ switch variant {
2216
+
2217
+ case 1: return .missing
2218
+
2219
+ case 2: return .malformed
2220
+
2221
+ case 3: return .unknownVersion
2222
+
2223
+ case 4: return .undecryptable
2224
+
2225
+ case 5: return .openingMismatch
2226
+
2227
+ case 6: return .notConfidential
2228
+
2229
+ default: throw UniffiInternalError.unexpectedEnumCase
2230
+ }
2231
+ }
2232
+
2233
+ public static func write(_ value: NoteFailure, into buf: inout [UInt8]) {
2234
+ switch value {
2235
+
2236
+
2237
+ case .missing:
2238
+ writeInt(&buf, Int32(1))
2239
+
2240
+
2241
+ case .malformed:
2242
+ writeInt(&buf, Int32(2))
2243
+
2244
+
2245
+ case .unknownVersion:
2246
+ writeInt(&buf, Int32(3))
2247
+
2248
+
2249
+ case .undecryptable:
2250
+ writeInt(&buf, Int32(4))
2251
+
2252
+
2253
+ case .openingMismatch:
2254
+ writeInt(&buf, Int32(5))
2255
+
2256
+
2257
+ case .notConfidential:
2258
+ writeInt(&buf, Int32(6))
2259
+
2260
+ }
2261
+ }
2262
+ }
2263
+
2264
+
2265
+ #if swift(>=5.8)
2266
+ @_documentation(visibility: private)
2267
+ #endif
2268
+ public func FfiConverterTypeNoteFailure_lift(_ buf: RustBuffer) throws -> NoteFailure {
2269
+ return try FfiConverterTypeNoteFailure.lift(buf)
2270
+ }
2271
+
2272
+ #if swift(>=5.8)
2273
+ @_documentation(visibility: private)
2274
+ #endif
2275
+ public func FfiConverterTypeNoteFailure_lower(_ value: NoteFailure) -> RustBuffer {
2276
+ return FfiConverterTypeNoteFailure.lower(value)
2277
+ }
2278
+
2279
+
2280
+
2281
+ /**
2282
+ * What a [`Wallet`] was built from, and so what it can do. Each kind can
2283
+ * do everything the next one can.
2284
+ */
2285
+
2286
+ public enum WalletKind: Equatable, Hashable {
2287
+
2288
+ /**
2289
+ * From a seed or mnemonic: finds, opens and spends.
2290
+ */
2291
+ case spend
2292
+ /**
2293
+ * From a view key: finds and opens every payment, cannot spend.
2294
+ */
2295
+ case view
2296
+ /**
2297
+ * From a receiving key: finds every payment, cannot open or spend.
2298
+ */
2299
+ case receive
2300
+
2301
+
2302
+
2303
+
2304
+
2305
+ }
2306
+
2307
+ #if compiler(>=6)
2308
+ extension WalletKind: Sendable {}
2309
+ #endif
2310
+
2311
+ #if swift(>=5.8)
2312
+ @_documentation(visibility: private)
2313
+ #endif
2314
+ public struct FfiConverterTypeWalletKind: FfiConverterRustBuffer {
2315
+ typealias SwiftType = WalletKind
2316
+
2317
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> WalletKind {
2318
+ let variant: Int32 = try readInt(&buf)
2319
+ switch variant {
2320
+
2321
+ case 1: return .spend
2322
+
2323
+ case 2: return .view
2324
+
2325
+ case 3: return .receive
2326
+
2327
+ default: throw UniffiInternalError.unexpectedEnumCase
2328
+ }
2329
+ }
2330
+
2331
+ public static func write(_ value: WalletKind, into buf: inout [UInt8]) {
2332
+ switch value {
2333
+
2334
+
2335
+ case .spend:
2336
+ writeInt(&buf, Int32(1))
2337
+
2338
+
2339
+ case .view:
2340
+ writeInt(&buf, Int32(2))
2341
+
2342
+
2343
+ case .receive:
2344
+ writeInt(&buf, Int32(3))
2345
+
2346
+ }
2347
+ }
2348
+ }
2349
+
2350
+
2351
+ #if swift(>=5.8)
2352
+ @_documentation(visibility: private)
2353
+ #endif
2354
+ public func FfiConverterTypeWalletKind_lift(_ buf: RustBuffer) throws -> WalletKind {
2355
+ return try FfiConverterTypeWalletKind.lift(buf)
2356
+ }
2357
+
2358
+ #if swift(>=5.8)
2359
+ @_documentation(visibility: private)
2360
+ #endif
2361
+ public func FfiConverterTypeWalletKind_lower(_ value: WalletKind) -> RustBuffer {
2362
+ return FfiConverterTypeWalletKind.lower(value)
2363
+ }
2364
+
2365
+
1896
2366
  #if swift(>=5.8)
1897
2367
  @_documentation(visibility: private)
1898
2368
  #endif
@@ -2151,7 +2621,10 @@ private let initializationResult: InitializationResult = {
2151
2621
  if (uniffi_flamewallet_ffi_checksum_method_wallet_address() != 24772) {
2152
2622
  return InitializationResult.apiChecksumMismatch
2153
2623
  }
2154
- if (uniffi_flamewallet_ffi_checksum_method_wallet_build_transfer() != 41970) {
2624
+ if (uniffi_flamewallet_ffi_checksum_method_wallet_build_transfer() != 38498) {
2625
+ return InitializationResult.apiChecksumMismatch
2626
+ }
2627
+ if (uniffi_flamewallet_ffi_checksum_method_wallet_kind() != 48257) {
2155
2628
  return InitializationResult.apiChecksumMismatch
2156
2629
  }
2157
2630
  if (uniffi_flamewallet_ffi_checksum_method_wallet_network() != 6461) {
@@ -2163,15 +2636,27 @@ private let initializationResult: InitializationResult = {
2163
2636
  if (uniffi_flamewallet_ffi_checksum_method_wallet_next_index() != 50043) {
2164
2637
  return InitializationResult.apiChecksumMismatch
2165
2638
  }
2639
+ if (uniffi_flamewallet_ffi_checksum_method_wallet_open_note() != 63642) {
2640
+ return InitializationResult.apiChecksumMismatch
2641
+ }
2166
2642
  if (uniffi_flamewallet_ffi_checksum_method_wallet_owns() != 34274) {
2167
2643
  return InitializationResult.apiChecksumMismatch
2168
2644
  }
2169
2645
  if (uniffi_flamewallet_ffi_checksum_method_wallet_receiving_key() != 41950) {
2170
2646
  return InitializationResult.apiChecksumMismatch
2171
2647
  }
2648
+ if (uniffi_flamewallet_ffi_checksum_method_wallet_view_key() != 51879) {
2649
+ return InitializationResult.apiChecksumMismatch
2650
+ }
2172
2651
  if (uniffi_flamewallet_ffi_checksum_constructor_wallet_from_mnemonic() != 19125) {
2173
2652
  return InitializationResult.apiChecksumMismatch
2174
2653
  }
2654
+ if (uniffi_flamewallet_ffi_checksum_constructor_wallet_from_receiving_key() != 30262) {
2655
+ return InitializationResult.apiChecksumMismatch
2656
+ }
2657
+ if (uniffi_flamewallet_ffi_checksum_constructor_wallet_from_view_key() != 5669) {
2658
+ return InitializationResult.apiChecksumMismatch
2659
+ }
2175
2660
  if (uniffi_flamewallet_ffi_checksum_constructor_wallet_new() != 9773) {
2176
2661
  return InitializationResult.apiChecksumMismatch
2177
2662
  }